ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Farm Class Reference

The base class for all farm types. More...

#include <farm.h>

Inheritance diagram for Farm:
AgroChemIndustryCerealFarm1 AgroChemIndustryCerealFarm2 AgroChemIndustryCerealFarm3 ConvMarginalJord ConventionalCattle ConventionalPig ConventionalPlant NoPesticideBaseFarm NoPesticideNoPFarm OptimisingFarm OrganicCattle OrganicPig OrganicPlant PesticideTrialControl PesticideTrialToxicControl PesticideTrialTreatment UserDefinedFarm UserDefinedFarm1 UserDefinedFarm10 UserDefinedFarm11 UserDefinedFarm12 UserDefinedFarm13 UserDefinedFarm14 UserDefinedFarm15 UserDefinedFarm16 UserDefinedFarm17 UserDefinedFarm2 UserDefinedFarm3 UserDefinedFarm4 UserDefinedFarm5 UserDefinedFarm6 UserDefinedFarm7 UserDefinedFarm8 UserDefinedFarm9

Public Member Functions

virtual void Management (void)
 Starts the main management loop for the farm and performs some error checking. More...
 
virtual void InitiateManagement (void)
 Kicks off the farm's management. More...
 
void AddField (LE *a_newfield)
 Adds a field to a farm. More...
 
void RemoveField (LE *a_field)
 Removes a field from a farm. More...
 
 Farm (FarmManager *a_manager)
 Farm constructor - creates an instance of each possible crop type. More...
 
virtual ~Farm (void)
 Farm destructor - deletes all crop instances and empties event queues. More...
 
void SetFarmNumber (int a_farm_num)
 
int GetFarmNumber (void)
 
virtual bool Spraying_herbicides (TTypesOfVegetation)
 
virtual bool Spraying_fungins (TTypesOfVegetation)
 
virtual double Prob_multiplier ()
 
void Assign_rotation (vector< TTypesOfVegetation >a_new_rotation)
 
polylistListOpenFields (int a_openness)
 Returns a list of fields with openness above a_openness. More...
 
void Centroids ()
 Finds farm's centroids - x and y. More...
 
int GetNoFields ()
 Returns the number of the fields owned. More...
 
int GetNoOpenFields (int a_openness)
 Returns the number of the fields above an openness of a_openness. More...
 
int GetAreaOpenFields (int a_openness)
 Returns the area of the fields above an openness of a_openness. More...
 
APoint GetValidCoords ()
 Returns the valid coordinates of the first field owned by a farm. More...
 
int GetMaxOpenness ()
 Returns the maximum openness score of the fields. More...
 
virtual bool SleepAllDay (LE *a_field, double a_user, int a_days)
 Nothing to to today on a_field. More...
 
virtual bool AutumnPlough (LE *a_field, double a_user, int a_days)
 Carry out a ploughing event in the autumn on a_field. More...
 
virtual bool StubblePlough (LE *a_field, double a_user, int a_days)
 Carry out a stubble ploughing event on a_field. This is similar to normal plough but shallow (normally 6-8cm, is special cases up to 12-15cm). Done as a part of after-harvest treatments (instead of stubble cultivation) More...
 
virtual bool StubbleCultivatorHeavy (LE *a_field, double a_user, int a_days)
 Carry out a stubble cultivation event on a_field. This is non-inversion type of cultivation which can be done instead of autumn plough (on a depth up to 40 cm even, if necessary) More...
 
virtual bool AutumnHarrow (LE *a_field, double a_user, int a_days)
 Carry out a harrow event in the autumn on a_field. More...
 
virtual bool AutumnRoll (LE *a_field, double a_user, int a_days)
 Carry out a roll event in the autumn on a_field. More...
 
virtual bool PreseedingCultivator (LE *a_field, double a_user, int a_days)
 Carry out preseeding cultivation on a_field (tilling set including cultivator and string roller to compact soil) More...
 
virtual bool PreseedingCultivatorSow (LE *a_field, double a_user, int a_days)
 Carry out preseeding cultivation together with sow on a_field (tilling and sowing set including cultivator and string roller to compact soil) More...
 
virtual bool AutumnSow (LE *a_field, double a_user, int a_days)
 Carry out a sowing event in the autumn on a_field. More...
 
virtual bool WinterPlough (LE *a_field, double a_user, int a_days)
 Carry out a ploughing event in the winter on a_field. More...
 
virtual bool DeepPlough (LE *a_field, double a_user, int a_days)
 Carry out a deep ploughing event on a_field. More...
 
virtual bool SpringPlough (LE *a_field, double a_user, int a_days)
 Carry out a ploughing event in the spring on a_field. More...
 
virtual bool SpringHarrow (LE *a_field, double a_user, int a_days)
 Carry out a harrow event in the spring on a_field. More...
 
virtual bool SpringRoll (LE *a_field, double a_user, int a_days)
 Carry out a roll event in the spring on a_field. More...
 
virtual bool SpringSow (LE *a_field, double a_user, int a_days)
 Carry out a sowing event in the spring on a_field. More...
 
virtual bool SpringSowWithFerti (LE *a_field, double a_user, int a_days)
 Carry out a sowing event with start fertilizer in the spring on a_field. More...
 
virtual bool HerbicideTreat (LE *a_field, double a_user, int a_days)
 Apply herbicide to a_field. More...
 
virtual bool GrowthRegulator (LE *a_field, double a_user, int a_days)
 Apply growth regulator to a_field. More...
 
virtual bool FungicideTreat (LE *a_field, double a_user, int a_days)
 Apply fungicide to a_field. More...
 
virtual bool InsecticideTreat (LE *a_field, double a_user, int a_days)
 Apply insecticide to a_field. More...
 
virtual bool ProductApplication (LE *a_field, double a_user, int a_days, double a_applicationrate, PlantProtectionProducts a_ppp)
 Apply test pesticide to a_field. More...
 
virtual bool ProductApplication_DateLimited (LE *a_field, double, int, double a_applicationrate, PlantProtectionProducts a_ppp)
 Special pesticide trial functionality. More...
 
virtual bool Molluscicide (LE *a_field, double a_user, int a_days)
 Apply molluscidie to a_field. More...
 
virtual bool RowCultivation (LE *a_field, double a_user, int a_days)
 Carry out a harrowing between crop rows on a_field. More...
 
virtual bool Strigling (LE *a_field, double a_user, int a_days)
 Carry out a mechanical weeding on a_field. More...
 
virtual bool StriglingSow (LE *a_field, double a_user, int a_days)
 Carry out a mechanical weeding followed by sowing on a_field. More...
 
virtual bool StriglingHill (LE *a_field, double a_user, int a_days)
 Carry out a mechanical weeding on a_field followed by hilling up (probably on potatoes) More...
 
virtual bool HillingUp (LE *a_field, double a_user, int a_days)
 Do hilling up on a_field, probably of potatoes. More...
 
virtual bool Water (LE *a_field, double a_user, int a_days)
 Carry out a watering on a_field. More...
 
virtual bool Swathing (LE *a_field, double a_user, int a_days)
 Cut the crop on a_field and leave it lying (probably rape) More...
 
virtual bool Harvest (LE *a_field, double a_user, int a_days)
 Carry out a harvest on a_field. More...
 
virtual bool HarvestLong (LE *a_field, double a_user, int a_days)
 Carry out a harvest on a_field. More...
 
virtual bool CattleOut (LE *a_field, double a_user, int a_days)
 Start a grazing event on a_field today. More...
 
virtual bool CattleOutLowGrazing (LE *a_field, double a_user, int a_days)
 Start a extensive grazing event on a_field today. More...
 
virtual bool CattleIsOut (LE *a_field, double a_user, int a_days, int a_max)
 Generate a 'cattle_out' event for every day the cattle are on a_field. More...
 
virtual bool CattleIsOutLow (LE *a_field, double a_user, int a_days, int a_max)
 Generate a 'cattle_out_low' event for every day the cattle are on a_field. More...
 
virtual bool PigsOut (LE *a_field, double a_user, int a_days)
 Generate a 'pigs_out' event for every day the cattle are on a_field. More...
 
virtual bool PigsAreOut (LE *a_field, double a_user, int a_days)
 Start a pig grazing event on a_field today or soon. More...
 
virtual bool PigsAreOutForced (LE *a_field, double a_user, int a_days)
 Start a pig grazing event on a_field today - no exceptions. More...
 
virtual bool CutToHay (LE *a_field, double a_user, int a_days)
 Carry out hay cutting on a_field. More...
 
virtual bool CutWeeds (LE *a_field, double a_user, int a_days)
 Carry out weed topping on a_field. More...
 
virtual bool CutToSilage (LE *a_field, double a_user, int a_days)
 Cut vegetation for silage on a_field. More...
 
virtual bool CutOrch (LE *a_field, double a_user, int a_days)
 Cut vegetation on orchard crop. //based on cut to silage - values from cutting function of orchard. More...
 
virtual bool StrawChopping (LE *a_field, double a_user, int a_days)
 Carry out straw chopping on a_field. More...
 
virtual bool HayTurning (LE *a_field, double a_user, int a_days)
 Carry out hay turning on a_field. More...
 
virtual bool HayBailing (LE *a_field, double a_user, int a_days)
 Carry out hay bailing on a_field. More...
 
virtual bool BurnStrawStubble (LE *a_field, double a_user, int a_days)
 Burn stubble on a_field. More...
 
virtual bool StubbleHarrowing (LE *a_field, double a_user, int a_days)
 Carry out stubble harrowing on a_field. More...
 
virtual bool FP_NPKS (LE *a_field, double a_user, int a_days)
 Apply NPKS fertilizer, on a_field owned by an arable farmer. More...
 
virtual bool FP_NPK (LE *a_field, double a_user, int a_days)
 Apply NPK fertilizer, on a_field owned by an arable farmer. More...
 
virtual bool FP_PK (LE *a_field, double a_user, int a_days)
 Apply PK fertilizer, on a_field owned by an arable farmer. More...
 
virtual bool FP_LiquidNH3 (LE *a_field, double a_user, int a_days)
 Apply liquid ammonia fertilizer to a_field owned by an arable farmer. More...
 
virtual bool FP_Slurry (LE *a_field, double a_user, int a_days)
 Apply slurry to a_field owned by an arable farmer. More...
 
virtual bool FP_ManganeseSulphate (LE *a_field, double a_user, int a_days)
 Apply Manganse Sulphate to a_field owned by an arable farmer. More...
 
virtual bool FP_AmmoniumSulphate (LE *a_field, double a_user, int a_days)
 Apply Ammonium Sulphate to a_field owned by an arable farmer. More...
 
virtual bool FP_Manure (LE *a_field, double a_user, int a_days)
 Spread manure on a_field owned by an arable farmer. More...
 
virtual bool FP_GreenManure (LE *a_field, double a_user, int a_days)
 Spread green manure on a_field owned by an arable farmer. More...
 
virtual bool FP_Sludge (LE *a_field, double a_user, int a_days)
 Spread sewege on a_field owned by an arable farmer. More...
 
virtual bool FP_RSM (LE *a_field, double a_user, int a_days)
 RSM (ammonium nitrate solution) applied on a_field owned by an arable farmer. More...
 
virtual bool FP_Calcium (LE *a_field, double a_user, int a_days)
 Calcium applied on a_field owned by an arable farmer. More...
 
virtual bool FA_NPKS (LE *a_field, double a_user, int a_days)
 Apply NPKS fertilizer, on a_field owned by a stock farmer. More...
 
virtual bool FA_NPK (LE *a_field, double a_user, int a_days)
 Apply NPK fertilizer to a_field owned by an stock farmer. More...
 
virtual bool FA_PK (LE *a_field, double a_user, int a_days)
 Apply PK fertilizer to a_field owned by an stock farmer. More...
 
virtual bool FA_Slurry (LE *a_field, double a_user, int a_days)
 Spready slurry on a_field owned by an stock farmer. More...
 
virtual bool FA_ManganeseSulphate (LE *a_field, double a_user, int a_days)
 Apply manganese sulphate to a_field owned by an stock farmer. More...
 
virtual bool FA_AmmoniumSulphate (LE *a_field, double a_user, int a_days)
 Apply ammonium sulphate to a_field owned by an stock farmer. More...
 
virtual bool FA_Manure (LE *a_field, double a_user, int a_days)
 Spread manure on a_field owned by an stock farmer. More...
 
virtual bool FA_GreenManure (LE *a_field, double a_user, int a_days)
 Spread green manure on a_field owned by an stock farmer. More...
 
virtual bool FA_Sludge (LE *a_field, double a_user, int a_days)
 Spread sewege sludge on a_field owned by an stock farmer. More...
 
virtual bool FA_RSM (LE *a_field, double a_user, int a_days)
 RSM (ammonium nitrate solution) applied on a_field owned by a stock farmer. More...
 
virtual bool FA_Calcium (LE *a_field, double a_user, int a_days)
 Calcium applied on a_field owned by a stock farmer. More...
 
virtual bool Biocide (LE *a_field, double a_user, int a_days)
 Biocide applied on a_field. More...
 
virtual bool BedForming (LE *a_field, double a_user, int a_days)
 Do bed forming up on a_field, probably of carrots. More...
 
virtual bool ShallowHarrow (LE *a_field, double a_user, int a_days)
 Carry out a shallow harrow event on a_field, e.g., after grass cutting event. More...
 
virtual bool HeavyCultivatorAggregate (LE *a_field, double a_user, int a_days)
 Carry out a heavy cultivation event on a_field. This is non-inversion type of cultivation which can be done after fertilizers application on spring for a spring crop. More...
 
virtual bool FlowerCutting (LE *a_field, double a_user, int a_days)
 Flower cutting applied on a_field. More...
 
virtual bool BulbHarvest (LE *a_field, double a_user, int a_days)
 Carry out a bulb harvest on a_field. More...
 
virtual bool StrawCovering (LE *a_field, double a_user, int a_days)
 Straw covering applied on a_field. More...
 
virtual bool StrawRemoval (LE *a_field, double a_user, int a_days)
 Straw covering applied on a_field. More...
 
void AddNewEvent (TTypesOfVegetation a_event, long a_date, LE *a_field, int a_todo, long a_num, bool a_lock, int a_start, bool a_first_year, TTypesOfVegetation a_crop)
 Adds an event to the event queue for a farm. More...
 
bool DoIt (double a_probability)
 Return chance out of 0 to 100. More...
 
bool DoIt_prob (double a_probability)
 Return chance out of 0 to 1. More...
 
TTypesOfFarm GetType (void)
 
int GetArea (void)
 Returns the area of arable fields owned by that farm. More...
 
int GetTotalArea (void)
 Returns the area of all fields owned by that farm. More...
 
double GetAreaDouble (void)
 Returns the area of arable fields owned by that farm. More...
 
bool IsStockFarmer (void)
 
virtual void MakeStockFarmer (void)
 
int GetIntensity (void)
 
APoint GetCentroids ()
 
TTypesOfVegetation GetPreviousCrop (int a_index)
 
TTypesOfVegetation GetCrop (int a_index)
 
TTypesOfVegetation GetNextCrop (int a_index)
 
void AddHunter (Hunter *a_hunter)
 
void RemoveHunter (Hunter *a_hunter)
 

Protected Member Functions

int GetFirstDate (TTypesOfVegetation a_tov)
 Gets the start date for a crop type. More...
 
int GetNextCropStartDate (LE *a_field, TTypesOfVegetation &a_curr_veg)
 Returns the start date of the next crop in the rotation. More...
 
virtual int GetFirstCropIndex (TTypesOfLandscapeElement a_type)
 Gets the first crop for the farm. More...
 
virtual int GetNextCropIndex (int a_rot_index)
 Returns the next crop in the rotation. More...
 
virtual void HandleEvents (void)
 If there are events to carry out do this, and perhaps start a new crop. More...
 
bool LeSwitch (FarmEvent *ev)
 Call do function for any crop with an outstanding event. Signal if the crop has terminated. More...
 
void CheckRotationManagementLoop (FarmEvent *ev)
 
void ReadRotation (std::string fname)
 Reads a rotation file into the rotation. More...
 
void AssignPermanentCrop (TTypesOfVegetation tov, int pct)
 Used to assign a permanent crop to an otherwise rotational field polygon. More...
 
int InvIntPartition (vector< tpct > *items, int target)
 Finds all possible sums of the integers in the items array. More...
 

Protected Attributes

FarmManagerm_OurManager
 Pointer to the FarmManager. More...
 
LowPriority< FarmEvent * > m_queue
 
vector< LE * > m_fields
 
vector< TTypesOfVegetationm_rotation
 
vector< PermCropDatam_PermCrops
 
TTypesOfFarm m_farmtype
 
HunterList m_HuntersList
 A list of hunters allocated to this farm. More...
 
bool m_stockfarmer
 
int m_farm_num
 
int m_rotation_sync_index
 
int m_intensity
 
int m_farm_centroidx
 Farm's centroid, value x. Equal to the average of the x centroid values of all farm's fields. More...
 
int m_farm_centroidy
 Farm's centroid, value y. Equal to the average of the y centroid values of all farm's fields. More...
 
Carrots * m_carrots
 
BroadBeans * m_broadbeans
 
FodderGrass * m_foddergrass
 
CloverGrassGrazed1 * m_CGG1
 
CloverGrassGrazed2 * m_CGG2
 
FieldPeas * m_fieldpeas
 
FieldPeasSilage * m_fieldpeassilage
 
Fodderbeet * m_fodderbeet
 
Sugarbeet * m_sugarbeet
 
OFodderbeet * m_ofodderbeet
 
Maize * m_maize
 
MaizeSilage * m_maizesilage
 
OMaizeSilage * m_omaizesilage
 
OBarleyPeaCloverGrass * m_OBarleyPCG
 
OCarrots * m_ocarrots
 
OCloverGrassGrazed1 * m_OCGG1
 
OCloverGrassGrazed2 * m_OCGG2
 
OCloverGrassSilage1 * m_OCGS1
 
OFieldPeas * m_ofieldpeas
 
OFieldPeasSilage * m_ofieldpeassilage
 
OFirstYearDanger * m_ofirstyeardanger
 
OGrazingPigs * m_ograzingpigs
 
OrchardCrop * m_orchardcrop
 
Oats * m_oats
 
OOats * m_ooats
 
OPermanentGrassGrazed * m_opermgrassgrazed
 
OPotatoes * m_opotatoes
 
OSeedGrass1 * m_oseedgrass1
 
OSeedGrass2 * m_oseedgrass2
 
OSpringBarley * m_ospringbarley
 
OSpringBarleyExt * m_ospringbarleyext
 
OSpringBarleyPigs * m_ospringbarleypigs
 
OSBarleySilage * m_osbarleysilage
 
OTriticale * m_otriticale
 
OWinterBarley * m_owinterbarley
 
OWinterBarleyExt * m_owinterbarleyext
 
OWinterRape * m_owinterrape
 
OWinterRye * m_owinterrye
 
OWinterWheatUndersown * m_owinterwheatundersown
 
OWinterWheat * m_owinterwheat
 
OWinterWheatUndersownExt * m_owinterwheatundersownext
 
PermanentGrassGrazed * m_permgrassgrazed
 
PermanentGrassLowYield * m_permgrasslowyield
 
PermanentGrassTussocky * m_permgrasstussocky
 
PermanentSetAside * m_permanentsetaside
 
Potatoes * m_potatoes
 
PotatoesIndustry * m_potatoesindustry
 
SeedGrass1 * m_seedgrass1
 
SeedGrass2 * m_seedgrass2
 
SetAside * m_setaside
 
SpringBarley * m_springbarley
 
SpringBarleySpr * m_springbarleyspr
 
SpringBarleySKManagement * m_springbarleyskmanagement
 
SpringBarleyPTreatment * m_springbarleyptreatment
 
SpringBarleyCloverGrass * m_sbarleyclovergrass
 
SpringBarleySeed * m_springbarleyseed
 
SpringBarleySilage * m_springbarleysilage
 
SpringRape * m_springrape
 
Triticale * m_triticale
 
WinterBarley * m_winterbarley
 
WinterRape * m_winterrape
 
WinterRye * m_winterrye
 
WinterWheat * m_winterwheat
 
WWheatPControl * m_wwheatpcontrol
 
WWheatPToxicControl * m_wwheatptoxiccontrol
 
WWheatPTreatment * m_wwheatptreatment
 
AgroChemIndustryCereal * m_agrochemindustrycereal
 
WinterWheatStrigling * m_winterwheatstrigling
 
WinterWheatStriglingCulm * m_winterwheatstriglingculm
 
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
 
SpringBarleyCloverGrassStrigling * m_springbarleyclovergrassstrigling
 
SpringBarleyStrigling * m_springbarleystrigling
 
SpringBarleyStriglingCulm * m_springbarleystriglingculm
 
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
 
MaizeStrigling * m_maizestrigling
 
WinterRapeStrigling * m_winterrapestrigling
 
WinterRyeStrigling * m_winterryestrigling
 
WinterBarleyStrigling * m_winterbarleystrigling
 
FieldPeasStrigling * m_fieldpeasstrigling
 
SpringBarleyPeaCloverGrassStrigling * m_springbarleypeaclovergrassstrigling
 
YoungForestCrop * m_youngforest
 
NorwegianPotatoes * m_norwegianpotatoes
 
NorwegianOats * m_norwegianoats
 
NorwegianSpringBarley * m_norwegianspringbarley
 
PLWinterWheat * m_plwinterwheat
 
PLWinterRape * m_plwinterrape
 
PLWinterBarley * m_plwinterbarley
 
PLWinterTriticale * m_plwintertriticale
 
PLWinterRye * m_plwinterrye
 
PLSpringWheat * m_plspringwheat
 
PLSpringBarley * m_plspringbarley
 
PLMaize * m_plmaize
 
PLMaizeSilage * m_plmaizesilage
 
PLPotatoes * m_plpotatoes
 
PLBeet * m_plbeet
 
PLFodderLucerne1 * m_plfodderlucerne1
 
PLFodderLucerne2 * m_plfodderlucerne2
 
PLCarrots * m_plcarrots
 
PLSpringBarleySpr * m_plspringbarleyspr
 
PLWinterWheatLate * m_plwinterwheatlate
 
PLBeetSpr * m_plbeetspr
 
PLBeans * m_plbeans
 
NLBeet * m_nlbeet
 
NLCarrots * m_nlcarrots
 
NLMaize * m_nlmaize
 
NLPotatoes * m_nlpotatoes
 
NLSpringBarley * m_nlspringbarley
 
NLWinterWheat * m_nlwinterwheat
 
NLCabbage * m_nlcabbage
 
NLTulips * m_nltulips
 
NLGrassGrazed1 * m_nlgrassgrazed1
 
NLGrassGrazed1Spring * m_nlgrassgrazed1spring
 
NLGrassGrazed2 * m_nlgrassgrazed2
 
NLGrassGrazedLast * m_nlgrassgrazedlast
 
NLPermanentGrassGrazed * m_nlpermanentgrassgrazed
 
NLBeetSpring * m_nlbeetspring
 
NLCarrotsSpring * m_nlcarrotsspring
 
NLMaizeSpring * m_nlmaizespring
 
NLPotatoesSpring * m_nlpotatoesspring
 
NLSpringBarleySpring * m_nlspringbarleyspring
 
NLCabbageSpring * m_nlcabbagespring
 
NLCatchPeaCrop * m_nlcatchpeacrop
 
DummyCropPestTesting * m_dummycroppesttesting
 

Detailed Description

The base class for all farm types.

Constructor & Destructor Documentation

◆ Farm()

Farm::Farm ( FarmManager a_manager)

Farm constructor - creates an instance of each possible crop type.

1059 {
1060  m_OurManager = a_manager;
1061  m_carrots = new Carrots;
1062  m_broadbeans = new BroadBeans;
1063  m_CGG1 = new CloverGrassGrazed1;
1064  m_CGG2 = new CloverGrassGrazed2;
1065  m_fieldpeas = new FieldPeas;
1066  m_fieldpeassilage = new FieldPeasSilage;
1067  m_fodderbeet = new Fodderbeet;
1068  m_sugarbeet = new Sugarbeet;
1069  m_ofodderbeet = new OFodderbeet;
1070  m_foddergrass = new FodderGrass;
1071  m_maize = new Maize;
1072  m_maizesilage = new MaizeSilage;
1073  m_omaizesilage = new OMaizeSilage;
1074  m_OBarleyPCG = new OBarleyPeaCloverGrass;
1075  m_ocarrots = new OCarrots;
1076  m_OCGG1 = new OCloverGrassGrazed1;
1077  m_OCGG2 = new OCloverGrassGrazed2;
1078  m_OCGS1 = new OCloverGrassSilage1;
1079  m_ofieldpeas = new OFieldPeas;
1080  m_ofieldpeassilage = new OFieldPeasSilage;
1081  m_ofirstyeardanger = new OFirstYearDanger;
1082  m_ograzingpigs = new OGrazingPigs;
1083  m_orchardcrop = new OrchardCrop;
1084  m_oats = new Oats;
1085  m_ooats = new OOats;
1086  m_opermgrassgrazed = new OPermanentGrassGrazed;
1087  m_opotatoes = new OPotatoes;
1088  m_oseedgrass1 = new OSeedGrass1;
1089  m_oseedgrass2 = new OSeedGrass2;
1090  m_ospringbarley = new OSpringBarley;
1091  m_osbarleysilage = new OSBarleySilage;
1092  m_ospringbarleyext = new OSpringBarleyExt;
1093  m_ospringbarleypigs = new OSpringBarleyPigs;
1094  m_owinterbarley = new OWinterBarley;
1095  m_owinterbarleyext = new OWinterBarleyExt;
1096  m_owinterrape = new OWinterRape;
1097  m_owinterrye = new OWinterRye;
1098  m_owinterwheat = new OWinterWheat;
1099  m_owinterwheatundersown = new OWinterWheatUndersown;
1100  m_owinterwheatundersownext = new OWinterWheatUndersownExt;
1101  m_permanentsetaside = new PermanentSetAside;
1102  m_permgrassgrazed = new PermanentGrassGrazed;
1103  m_permgrasslowyield = new PermanentGrassLowYield;
1104  m_permgrasstussocky = new PermanentGrassTussocky;
1105  m_potatoes = new Potatoes;
1106  m_potatoesindustry = new PotatoesIndustry;
1107  m_sbarleyclovergrass = new SpringBarleyCloverGrass;
1108  m_seedgrass1 = new SeedGrass1;
1109  m_seedgrass2 = new SeedGrass2;
1110  m_setaside = new SetAside;
1111  m_springbarley = new SpringBarley;
1112  m_springbarleyspr = new SpringBarleySpr;
1113  m_springbarleyptreatment = new SpringBarleyPTreatment;
1114  m_springbarleyskmanagement = new SpringBarleySKManagement;
1115  m_springbarleyseed = new SpringBarleySeed;
1116  m_springbarleysilage = new SpringBarleySilage;
1117  m_springrape = new SpringRape;
1118  m_triticale = new Triticale;
1119  m_otriticale = new OTriticale;
1120  m_winterbarley = new WinterBarley;
1121  m_winterrape = new WinterRape;
1122  m_winterrye = new WinterRye;
1123  m_winterwheat = new WinterWheat;
1124  m_wwheatpcontrol = new WWheatPControl;
1125  m_wwheatptoxiccontrol = new WWheatPToxicControl;
1126  m_wwheatptreatment = new WWheatPTreatment;
1127  m_agrochemindustrycereal = new AgroChemIndustryCereal;
1128  m_winterwheatstrigling = new WinterWheatStrigling;
1129  m_winterwheatstriglingsingle = new WinterWheatStriglingSingle;
1130  m_winterwheatstriglingculm = new WinterWheatStriglingCulm;
1131  m_springbarleyclovergrassstrigling = new SpringBarleyCloverGrassStrigling;
1132  m_springbarleystrigling = new SpringBarleyStrigling;
1133  m_springbarleystriglingsingle = new SpringBarleyStriglingSingle;
1134  m_springbarleystriglingculm = new SpringBarleyStriglingCulm;
1135  m_maizestrigling = new MaizeStrigling;
1136  m_winterrapestrigling = new WinterRapeStrigling;
1137  m_winterryestrigling = new WinterRyeStrigling;
1138  m_winterbarleystrigling = new WinterBarleyStrigling;
1139  m_fieldpeasstrigling = new FieldPeasStrigling;
1140  m_springbarleypeaclovergrassstrigling = new SpringBarleyPeaCloverGrassStrigling;
1141  m_youngforest = new YoungForestCrop;
1142  m_norwegianpotatoes = new NorwegianPotatoes;
1143  m_norwegianoats = new NorwegianOats;
1144  m_norwegianspringbarley = new NorwegianSpringBarley;
1145  m_plwinterwheat = new PLWinterWheat;
1146  m_plwinterrape = new PLWinterRape;
1147  m_plwinterbarley = new PLWinterBarley;
1148  m_plwintertriticale = new PLWinterTriticale;
1149  m_plwinterrye = new PLWinterRye;
1150  m_plspringwheat = new PLSpringWheat;
1151  m_plspringbarley = new PLSpringBarley;
1152  m_plmaize = new PLMaize;
1153  m_plmaizesilage = new PLMaizeSilage;
1154  m_plpotatoes = new PLPotatoes;
1155  m_plbeet = new PLBeet;
1156  m_plfodderlucerne1 = new PLFodderLucerne1;
1157  m_plfodderlucerne2 = new PLFodderLucerne2;
1158  m_plcarrots = new PLCarrots;
1159  m_plspringbarleyspr = new PLSpringBarleySpr;
1160  m_plwinterwheatlate = new PLWinterWheatLate;
1161  m_plbeetspr = new PLBeetSpr;
1162  m_plbeans = new PLBeans;
1163 
1164  m_nlbeet = new NLBeet;
1165  m_nlcarrots = new NLCarrots;
1166  m_nlmaize = new NLMaize;
1167  m_nlpotatoes = new NLPotatoes;
1168  m_nlspringbarley = new NLSpringBarley;
1169  m_nlwinterwheat = new NLWinterWheat;
1170  m_nlcabbage = new NLCabbage;
1171  m_nltulips = new NLTulips;
1172  m_nlgrassgrazed1 = new NLGrassGrazed1;
1173  m_nlgrassgrazed1spring = new NLGrassGrazed1Spring;
1174  m_nlgrassgrazed2 = new NLGrassGrazed2;
1175  m_nlgrassgrazedlast = new NLGrassGrazedLast;
1176  m_nlpermanentgrassgrazed = new NLPermanentGrassGrazed;
1177  m_nlbeetspring = new NLBeetSpring;
1178  m_nlcarrotsspring = new NLCarrotsSpring;
1179  m_nlmaizespring = new NLMaizeSpring;
1180  m_nlpotatoesspring = new NLPotatoesSpring;
1181  m_nlspringbarleyspring = new NLSpringBarleySpring;
1182  m_nlcabbagespring = new NLCabbageSpring;
1183  m_nlcatchpeacrop = new NLCatchPeaCrop;
1184 
1185  m_dummycroppesttesting = new DummyCropPestTesting;
1186 
1187  m_rotation_sync_index = -1;
1188  // Defaults that need to be overridden when necessary
1189  m_stockfarmer = false;
1190  m_intensity = 0;
1191  m_HuntersList.resize(0); // Set the number of hunters to zero at the start.
1192 }
NLMaize * m_nlmaize
Definition: farm.h:1072
OPotatoes * m_opotatoes
Definition: farm.h:992
Potatoes * m_potatoes
Definition: farm.h:1011
WinterRapeStrigling * m_winterrapestrigling
Definition: farm.h:1041
OWinterWheatUndersownExt * m_owinterwheatundersownext
Definition: farm.h:1006
SeedGrass2 * m_seedgrass2
Definition: farm.h:1014
WinterWheatStriglingSingle * m_winterwheatstriglingsingle
Definition: farm.h:1035
PLMaize * m_plmaize
Definition: farm.h:1058
OSeedGrass2 * m_oseedgrass2
Definition: farm.h:994
MaizeSilage * m_maizesilage
Definition: farm.h:977
OCarrots * m_ocarrots
Definition: farm.h:980
int m_intensity
Definition: farm.h:946
OWinterRye * m_owinterrye
Definition: farm.h:1003
PLMaizeSilage * m_plmaizesilage
Definition: farm.h:1059
WinterRape * m_winterrape
Definition: farm.h:1026
NLBeetSpring * m_nlbeetspring
Definition: farm.h:1083
SpringBarleyPeaCloverGrassStrigling * m_springbarleypeaclovergrassstrigling
Definition: farm.h:1045
CloverGrassGrazed2 * m_CGG2
Definition: farm.h:970
PLWinterBarley * m_plwinterbarley
Definition: farm.h:1053
FarmManager * m_OurManager
Pointer to the FarmManager.
Definition: farm.h:935
OBarleyPeaCloverGrass * m_OBarleyPCG
Definition: farm.h:979
WWheatPControl * m_wwheatpcontrol
Definition: farm.h:1029
SpringBarleySKManagement * m_springbarleyskmanagement
Definition: farm.h:1018
NLMaizeSpring * m_nlmaizespring
Definition: farm.h:1085
PLSpringBarley * m_plspringbarley
Definition: farm.h:1057
OCloverGrassGrazed2 * m_OCGG2
Definition: farm.h:982
Oats * m_oats
Definition: farm.h:989
NLWinterWheat * m_nlwinterwheat
Definition: farm.h:1075
SpringBarleySilage * m_springbarleysilage
Definition: farm.h:1022
NLGrassGrazed1Spring * m_nlgrassgrazed1spring
Definition: farm.h:1079
NLPotatoes * m_nlpotatoes
Definition: farm.h:1073
OFieldPeasSilage * m_ofieldpeassilage
Definition: farm.h:985
OMaizeSilage * m_omaizesilage
Definition: farm.h:978
WinterRyeStrigling * m_winterryestrigling
Definition: farm.h:1042
OWinterRape * m_owinterrape
Definition: farm.h:1002
WinterWheat * m_winterwheat
Definition: farm.h:1028
PermanentGrassLowYield * m_permgrasslowyield
Definition: farm.h:1008
NLCarrots * m_nlcarrots
Definition: farm.h:1071
DummyCropPestTesting * m_dummycroppesttesting
Definition: farm.h:1091
BroadBeans * m_broadbeans
Definition: farm.h:967
PLWinterTriticale * m_plwintertriticale
Definition: farm.h:1054
OGrazingPigs * m_ograzingpigs
Definition: farm.h:987
SpringBarley * m_springbarley
Definition: farm.h:1016
NLGrassGrazedLast * m_nlgrassgrazedlast
Definition: farm.h:1081
OPermanentGrassGrazed * m_opermgrassgrazed
Definition: farm.h:991
NLSpringBarleySpring * m_nlspringbarleyspring
Definition: farm.h:1087
PLPotatoes * m_plpotatoes
Definition: farm.h:1060
NLCabbage * m_nlcabbage
Definition: farm.h:1076
SetAside * m_setaside
Definition: farm.h:1015
NorwegianSpringBarley * m_norwegianspringbarley
Definition: farm.h:1049
PLWinterWheat * m_plwinterwheat
Definition: farm.h:1051
OSeedGrass1 * m_oseedgrass1
Definition: farm.h:993
OWinterBarleyExt * m_owinterbarleyext
Definition: farm.h:1001
PLSpringWheat * m_plspringwheat
Definition: farm.h:1056
PLBeetSpr * m_plbeetspr
Definition: farm.h:1067
WinterWheatStriglingCulm * m_winterwheatstriglingculm
Definition: farm.h:1034
NLBeet * m_nlbeet
Definition: farm.h:1070
PLFodderLucerne1 * m_plfodderlucerne1
Definition: farm.h:1062
WWheatPTreatment * m_wwheatptreatment
Definition: farm.h:1031
SpringRape * m_springrape
Definition: farm.h:1023
PLBeans * m_plbeans
Definition: farm.h:1068
FodderGrass * m_foddergrass
Definition: farm.h:968
PLSpringBarleySpr * m_plspringbarleyspr
Definition: farm.h:1065
WinterRye * m_winterrye
Definition: farm.h:1027
MaizeStrigling * m_maizestrigling
Definition: farm.h:1040
SpringBarleyPTreatment * m_springbarleyptreatment
Definition: farm.h:1019
WinterBarley * m_winterbarley
Definition: farm.h:1025
OCloverGrassSilage1 * m_OCGS1
Definition: farm.h:983
OCloverGrassGrazed1 * m_OCGG1
Definition: farm.h:981
NLCatchPeaCrop * m_nlcatchpeacrop
Definition: farm.h:1089
NLPotatoesSpring * m_nlpotatoesspring
Definition: farm.h:1086
OFirstYearDanger * m_ofirstyeardanger
Definition: farm.h:986
OFodderbeet * m_ofodderbeet
Definition: farm.h:975
SpringBarleyStriglingSingle * m_springbarleystriglingsingle
Definition: farm.h:1039
OSpringBarley * m_ospringbarley
Definition: farm.h:995
SpringBarleyStriglingCulm * m_springbarleystriglingculm
Definition: farm.h:1038
OrchardCrop * m_orchardcrop
Definition: farm.h:988
WinterWheatStrigling * m_winterwheatstrigling
Definition: farm.h:1033
PotatoesIndustry * m_potatoesindustry
Definition: farm.h:1012
Fodderbeet * m_fodderbeet
Definition: farm.h:973
SpringBarleyCloverGrassStrigling * m_springbarleyclovergrassstrigling
Definition: farm.h:1036
OSpringBarleyExt * m_ospringbarleyext
Definition: farm.h:996
PLWinterRye * m_plwinterrye
Definition: farm.h:1055
FieldPeasStrigling * m_fieldpeasstrigling
Definition: farm.h:1044
OWinterBarley * m_owinterbarley
Definition: farm.h:1000
SpringBarleySpr * m_springbarleyspr
Definition: farm.h:1017
NLCabbageSpring * m_nlcabbagespring
Definition: farm.h:1088
SpringBarleySeed * m_springbarleyseed
Definition: farm.h:1021
NLCarrotsSpring * m_nlcarrotsspring
Definition: farm.h:1084
NLGrassGrazed1 * m_nlgrassgrazed1
Definition: farm.h:1078
HunterList m_HuntersList
A list of hunters allocated to this farm.
Definition: farm.h:942
OWinterWheatUndersown * m_owinterwheatundersown
Definition: farm.h:1004
OTriticale * m_otriticale
Definition: farm.h:999
Triticale * m_triticale
Definition: farm.h:1024
SpringBarleyStrigling * m_springbarleystrigling
Definition: farm.h:1037
NorwegianPotatoes * m_norwegianpotatoes
Definition: farm.h:1047
WWheatPToxicControl * m_wwheatptoxiccontrol
Definition: farm.h:1030
Sugarbeet * m_sugarbeet
Definition: farm.h:974
FieldPeas * m_fieldpeas
Definition: farm.h:971
NLGrassGrazed2 * m_nlgrassgrazed2
Definition: farm.h:1080
PLWinterRape * m_plwinterrape
Definition: farm.h:1052
OWinterWheat * m_owinterwheat
Definition: farm.h:1005
YoungForestCrop * m_youngforest
Definition: farm.h:1046
WinterBarleyStrigling * m_winterbarleystrigling
Definition: farm.h:1043
FieldPeasSilage * m_fieldpeassilage
Definition: farm.h:972
PermanentGrassTussocky * m_permgrasstussocky
Definition: farm.h:1009
bool m_stockfarmer
Definition: farm.h:943
NLPermanentGrassGrazed * m_nlpermanentgrassgrazed
Definition: farm.h:1082
OOats * m_ooats
Definition: farm.h:990
PLBeet * m_plbeet
Definition: farm.h:1061
OSpringBarleyPigs * m_ospringbarleypigs
Definition: farm.h:997
Maize * m_maize
Definition: farm.h:976
NLSpringBarley * m_nlspringbarley
Definition: farm.h:1074
int m_rotation_sync_index
Definition: farm.h:945
PLCarrots * m_plcarrots
Definition: farm.h:1064
AgroChemIndustryCereal * m_agrochemindustrycereal
Definition: farm.h:1032
NLTulips * m_nltulips
Definition: farm.h:1077
PLFodderLucerne2 * m_plfodderlucerne2
Definition: farm.h:1063
PLWinterWheatLate * m_plwinterwheatlate
Definition: farm.h:1066
OSBarleySilage * m_osbarleysilage
Definition: farm.h:998
PermanentGrassGrazed * m_permgrassgrazed
Definition: farm.h:1007
SeedGrass1 * m_seedgrass1
Definition: farm.h:1013
NorwegianOats * m_norwegianoats
Definition: farm.h:1048
Carrots * m_carrots
Definition: farm.h:966
OFieldPeas * m_ofieldpeas
Definition: farm.h:984
CloverGrassGrazed1 * m_CGG1
Definition: farm.h:969
PermanentSetAside * m_permanentsetaside
Definition: farm.h:1010
SpringBarleyCloverGrass * m_sbarleyclovergrass
Definition: farm.h:1020

◆ ~Farm()

Farm::~Farm ( void  )
virtual

Farm destructor - deletes all crop instances and empties event queues.

1199  {
1200  delete m_carrots;
1201  delete m_broadbeans;
1202  delete m_CGG2;
1203  delete m_CGG1;
1204  delete m_fieldpeas;
1205  delete m_fieldpeassilage;
1206  delete m_fodderbeet;
1207  delete m_sugarbeet;
1208  delete m_ofodderbeet;
1209  delete m_foddergrass;
1210  delete m_maizesilage;
1211  delete m_omaizesilage;
1212  delete m_maize;
1213  delete m_ocarrots;
1214  delete m_OCGG1;
1215  delete m_OCGG2;
1216  delete m_OCGS1;
1217  delete m_ofieldpeas;
1218  delete m_ofieldpeassilage;
1219  delete m_ofirstyeardanger;
1220  delete m_ograzingpigs;
1221  delete m_orchardcrop;
1222  delete m_ooats;
1223  delete m_oats;
1224  delete m_opermgrassgrazed;
1225  delete m_opotatoes;
1226  delete m_ospringbarley;
1227  delete m_ospringbarleyext;
1228  delete m_osbarleysilage;
1229  delete m_ospringbarleypigs;
1230  delete m_owinterbarley;
1231  delete m_owinterbarleyext;
1232  delete m_owinterrape;
1233  delete m_owinterrye;
1234  delete m_owinterwheatundersown;
1236  delete m_OBarleyPCG;
1237  delete m_permanentsetaside;
1238  delete m_permgrassgrazed;
1239  delete m_permgrasstussocky;
1240  delete m_permgrasslowyield;
1241  delete m_potatoes;
1242  delete m_potatoesindustry;
1243  delete m_sbarleyclovergrass;
1244  delete m_seedgrass2;
1245  delete m_seedgrass1;
1246  delete m_setaside;
1247  delete m_springbarley;
1248  delete m_springbarleyptreatment;
1250  delete m_springbarleyseed;
1251  delete m_springrape;
1252  delete m_springbarleysilage;
1253  delete m_agrochemindustrycereal;
1254  delete m_triticale;
1255  delete m_winterbarley;
1256  delete m_winterrape;
1257  delete m_winterrye;
1258  delete m_winterwheat;
1259  delete m_wwheatpcontrol;
1260  delete m_wwheatptoxiccontrol;
1261  delete m_wwheatptreatment;
1262  delete m_winterwheatstrigling;
1266  delete m_springbarleystrigling;
1269  delete m_maizestrigling;
1270  delete m_winterrapestrigling;
1271  delete m_winterryestrigling;
1272  delete m_winterbarleystrigling;
1273  delete m_fieldpeasstrigling;
1275  delete m_youngforest;
1276  delete m_norwegianoats;
1277  delete m_norwegianspringbarley;
1278 
1279  delete m_plwinterwheat;
1280  delete m_plwinterrape;
1281  delete m_plwinterbarley;
1282  delete m_plwintertriticale;
1283  delete m_plwinterrye;
1284  delete m_plspringwheat;
1285  delete m_plspringbarley;
1286  delete m_plmaize;
1287  delete m_plmaizesilage;
1288  delete m_plpotatoes;
1289  delete m_plbeet;
1290  delete m_plfodderlucerne1;
1291  delete m_plfodderlucerne2;
1292  delete m_plcarrots;
1293  delete m_plspringbarleyspr;
1294  delete m_plwinterwheatlate;
1295  delete m_plbeetspr;
1296  delete m_plbeans;
1297 
1298  delete m_nlbeet;
1299  delete m_nlcarrots;
1300  delete m_nlmaize;
1301  delete m_nlpotatoes;
1302  delete m_nlspringbarley;
1303  delete m_nlwinterwheat;
1304  delete m_nlcabbage;
1305  delete m_nltulips;
1306  delete m_nlgrassgrazed1;
1307  delete m_nlgrassgrazed1spring;
1308  delete m_nlgrassgrazed2;
1309  delete m_nlgrassgrazedlast;
1310  delete m_nlpermanentgrassgrazed;
1311  delete m_nlbeetspring;
1312  delete m_nlcarrotsspring;
1313  delete m_nlmaizespring;
1314  delete m_nlpotatoesspring;
1315  delete m_nlspringbarleyspring;
1316  delete m_nlcabbagespring;
1317  delete m_nlcatchpeacrop;
1318 
1319  delete m_dummycroppesttesting;
1320 
1322 
1323  while (!m_queue.Empty()) {
1324  pair = m_queue.Bottom();
1325  m_queue.Pop();
1326  delete pair.m_element;
1327  }
1328 }
LowPriority< FarmEvent * > m_queue
Definition: farm.h:936
void Pop()
Definition: lowqueue.h:124
bool Empty(void)
Definition: lowqueue.h:129
LowPriPair< ELEMTYPE > Bottom(void)
Definition: lowqueue.h:134
Used in event handling.
Definition: lowqueue.h:84
ELEMTYPE m_element
Definition: lowqueue.h:88

References LowPriPair< ELEMTYPE >::m_element.

Member Function Documentation

◆ AddField()

void Farm::AddField ( LE a_newfield)

Adds a field to a farm.

1447  {
1448  int i = (int) m_fields.size();
1449 
1450  m_fields.resize( i + 1 );
1451  m_fields[ i ] = a_newfield;
1452  // Must set the rot index to something other than -1, but identify it as not usefully set as yet.
1453  TTypesOfLandscapeElement ele = a_newfield->GetElementType();
1454  switch (ele) {
1456  case tole_YoungForest:
1457  case tole_PermPasture:
1460  case tole_Orchard:
1461  case tole_PlantNursery:
1462  m_fields[i]->SetRotIndex(-2);
1463  break;
1464  default:
1465  m_fields[ i ]->SetRotIndex(-1);
1466  }
1467 }
vector< LE * > m_fields
Definition: farm.h:937
virtual TTypesOfLandscapeElement GetElementType(void)
Definition: elements.h:113
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
@ tole_PermPastureTussocky
Definition: tole_declaration.h:45
@ tole_PermanentSetaside
Definition: tole_declaration.h:46
@ tole_PermPasture
Definition: tole_declaration.h:47
@ tole_PlantNursery
Definition: tole_declaration.h:95
@ tole_Orchard
Definition: tole_declaration.h:71
@ tole_YoungForest
Definition: tole_declaration.h:55
@ tole_PermPastureLowYield
Definition: tole_declaration.h:44

References LE::GetElementType(), tole_Orchard, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PlantNursery, and tole_YoungForest.

◆ AddHunter()

void Farm::AddHunter ( Hunter a_hunter)
inline
922  {
923  m_HuntersList.push_back( a_hunter );
924  }

References m_HuntersList.

◆ AddNewEvent()

void Farm::AddNewEvent ( TTypesOfVegetation  a_event,
long  a_date,
LE a_field,
int  a_todo,
long  a_num,
bool  a_lock,
int  a_start,
bool  a_first_year,
TTypesOfVegetation  a_crop 
)

Adds an event to the event queue for a farm.

790  {
791  FarmEvent * ev = new FarmEvent( a_event, a_field, a_todo, a_run, a_lock, a_start, a_first_year, a_crop );
792  m_queue.Push( ev, a_date );
793 }
void Push(ELEMTYPE a_element, long a_priority)
Definition: lowqueue.h:119
A struct to hold the information required to trigger a farm event.
Definition: farm.h:464

Referenced by Crop::SimpleEvent_().

◆ Assign_rotation()

void Farm::Assign_rotation ( vector< TTypesOfVegetation a_new_rotation)
1488  {
1489 
1490  m_rotation.clear();
1491  m_rotation = a_new_rotation;
1492 
1493 }
vector< TTypesOfVegetation > m_rotation
Definition: farm.h:938

Referenced by FarmManager::Switch_rotation().

◆ AssignPermanentCrop()

void Farm::AssignPermanentCrop ( TTypesOfVegetation  tov,
int  pct 
)
protected

Used to assign a permanent crop to an otherwise rotational field polygon.

2401  {
2402  // Assumes that m_fields has all the fields already in it, and those that are occupied by permanent tole types
2403  // are denoted by -2 or -4 in rotindex, -1 is unassigned - can't use enum because positive values have other meanings
2404 
2405  // Here we can save some time if we have to allocate all the fields to one permanent crop
2406  if (a_pct == 100)
2407  {
2408  for (auto cfi = m_fields.begin(); cfi != m_fields.end(); ++cfi)
2409  {
2410  // Set the field as non-rotating
2411  (*cfi)->SetRotIndex(-4);
2412  // Assign the crop, and weeds are assumed to be undefined
2413  (*cfi)->SetVegType(a_tov, tov_Undefined);
2414  }
2415  return;
2416  }
2417 
2418  tpct a_tpct;
2419  // create a copy of the field vector and call it fields_cpy
2420  vector<LE*> fields_cpy;
2421  fields_cpy.resize(m_fields.size());
2422  copy(m_fields.begin(), m_fields.end(), fields_cpy.begin());
2423  vector<tpct> pcts;
2424  double area = 0.0;
2425 
2426 
2427  // First get the areas of all fields and then convert these to percentages
2428  int sz = (int) fields_cpy.size();
2429  // loop through the fields vector and remove any fields already assigned to permanent crops
2430  for (int i = sz - 1; i >= 0; i--) {
2431  if (fields_cpy[i]->GetRotIndex() < -1) {
2432  fields_cpy.erase(fields_cpy.begin() + i);
2433  }
2434  }
2435  // sum up the area
2436  for (auto cfi = fields_cpy.begin(); cfi != fields_cpy.end(); ++cfi) area += (*cfi)->GetArea();
2437 
2438  // Here we can take action if we only have a single field
2439  int fnos = (int) fields_cpy.size();
2440  if (fnos<1) return; // No fields to allocate, jump out
2441  else if (fnos==1) {
2442  // Use the pct as the chance that our single field is assigned
2443  if (random(100)>=a_pct) return;
2444  else {
2445  // Add field by default
2446  fields_cpy[0]->SetRotIndex(-4);
2447  // Assign the crop
2448  fields_cpy[0]->SetVegType(a_tov, tov_Undefined);
2449  return;
2450  }
2451  }
2452  // By here we have more than one field to potentially allocate to
2453  for (int i=0; i<fnos; i++) {
2454  a_tpct.pct = (int) floor(0.5+((fields_cpy[i]->GetArea()/area)*100));
2455  a_tpct.index = i;
2456  pcts.push_back(a_tpct);
2457  }
2458  // We need to look for combinations of fields that are close to our target.
2459  // First we can sort the array and ignore any that are greater than pct
2460  sort (pcts.begin(), pcts.end(), CompPcts); // results in ordering on increasing pct
2461  // now remove all those with pct>target+10% to save loads of time in the inverse integer partition
2462  int index=-1;
2463  int ind=0;
2464  int apct=a_pct+10; // Lets assume we have a tolerance of 10%
2465  while ((index==-1) && (ind< (int)pcts.size())) {
2466  if (pcts[ind++].pct>apct) index=ind;
2467  }
2468  if (index!=-1) pcts.erase(pcts.begin()+index,pcts.end());
2469  // Now find the best combination of fields to get close to our target & set them
2470  int bits = InvIntPartition(&pcts,a_pct);
2471  int mask=1;
2472  ind = 0;
2473  int used=0;
2474  //double pctused = 0.0;
2475  double check = 0.0;
2476  for (int h=0; h< (int)pcts.size(); h++) check+=fields_cpy[pcts[h].index]->GetArea();
2477  while (bits>0) {
2478  if ((bits & mask) > 0) {
2479  // Set the field as non-rotating
2480  fields_cpy[pcts[ind].index]->SetRotIndex(-4);
2481  // Assign the crop
2482  fields_cpy[pcts[ind].index]->SetVegType(a_tov, tov_Undefined);
2483  used += (int) fields_cpy[pcts[ind].index]->GetArea();
2484  //pctused = used/area;
2485  bits -= mask;
2486  }
2487  mask = mask << 1;
2488  ind++;
2489  }
2490 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
int InvIntPartition(vector< tpct > *items, int target)
Finds all possible sums of the integers in the items array.
Definition: farm.cpp:2493
int GetArea(void)
Returns the area of arable fields owned by that farm.
Definition: farm.cpp:1331
bool CompPcts(tpct i, tpct j)
Used for sorting a farmers field size vector.
Definition: farm.cpp:294
Used for storing farmers field size vectors.
Definition: farm.h:454
int pct
Definition: farm.h:456
int index
Definition: farm.h:455
@ tov_Undefined
Definition: tov_declaration.h:114

References CompPcts(), GetArea(), tpct::index, InvIntPartition(), m_fields, tpct::pct, random(), and tov_Undefined.

Referenced by OptimisingFarm::InitiateManagement().

◆ AutumnHarrow()

bool Farm::AutumnHarrow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harrow event in the autumn on a_field.

262 {
263 
264  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
265  a_field->Trace( autumn_harrow );
266  a_field->SetLastTreatment( autumn_harrow );
267  // Apply 90% mortality to the insects
268  a_field->InsectMortality( 0.1 );
269  // Reduce the vegetation to zero
270  a_field->ZeroVeg();
271  int pref=a_field->GetUnsprayedMarginPolyRef();
272  if (pref!=-1){
273  // Must have an unsprayed margin so need to pass the information on to it
274  LE* um=g_landscape_p->SupplyLEPointer(pref);
276  um->InsectMortality( 0.1 );
277  um->ZeroVeg();
278  }
279  return true;
280  }
281  return false;
282 }
bool DoIt(double a_probability)
Return chance out of 0 to 100.
Definition: farm.cpp:800
Definition: elements.h:81
virtual void ZeroVeg(void)
Definition: elements.h:174
void Trace(int a_value)
Definition: elements.cpp:457
void SetLastTreatment(int a_treatment)
Definition: elements.cpp:490
int GetUnsprayedMarginPolyRef(void)
Definition: elements.h:319
virtual void InsectMortality(double)
Definition: elements.h:159
LE * SupplyLEPointer(int a_polyref)
Definition: landscape.h:1099
bool Raining(void)
Definition: weather.h:432
#define DO_IT_PROB
Definition: farmfuncs.cpp:56
Landscape * g_landscape_p
Definition: Landscape.cpp:258
@ autumn_harrow
Definition: treatment.h:37
class Weather * g_weather
Definition: weather.cpp:41

References autumn_harrow, DO_IT_PROB, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

◆ AutumnPlough()

bool Farm::AutumnPlough ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a ploughing event in the autumn on a_field.

133 {
134 
135  // LE is a pointer to the field element
136  // a_user is a pointer to the farm
137  // a_days is the end of the operation time - today
138  // if a_days <0 then the time to do it is passed
139  // the line below reads 'plough if last day possible OR if not raining and pass a probability test
140  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
141  // this bit sets up the events to occur when ploughing occurs
142  // The trace below is for debugging checks
143  a_field->Trace( autumn_plough );
144  // Record the event for this field, so other objects can find out it has happened
145  a_field->SetLastTreatment( autumn_plough );
146  // Apply mortality to the insects present, in this case 90%. This only affects the general insect model, any ALMaSS model species need to take their specific action.
147  a_field->InsectMortality( 0.1 );
148  // Reduce the vegetation, in this case to zero
149  a_field->ZeroVeg();
150  // If the field has a field margin, then do all this to the field margin too. In events that don't occur on an unsprayed margin, e.g. insecticide, then is part is skipped.
151  int pref=a_field->GetUnsprayedMarginPolyRef();
152  if (pref!=-1){
153  // Must have an unsprayed margin so need to pass the information on to it
154  LE* um=g_landscape_p->SupplyLEPointer(pref);
156  um->InsectMortality( 0.1 );
157  um->ZeroVeg();
158  }
159  return true; // completed
160  }
161  return false; // not completed
162 }
@ autumn_plough
Definition: treatment.h:34

References autumn_plough, DO_IT_PROB, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

◆ AutumnRoll()

bool Farm::AutumnRoll ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a roll event in the autumn on a_field.

289 {
290 
291  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
292  a_field->Trace( autumn_roll );
293  a_field->SetLastTreatment( autumn_roll );
294  a_field->ZeroVeg();
295  int pref=a_field->GetUnsprayedMarginPolyRef();
296  if (pref!=-1){
297  // Must have an unsprayed margin so need to pass the information on to it
298  LE* um=g_landscape_p->SupplyLEPointer(pref);
300  um->ZeroVeg();
301  }
302  return true;
303  }
304  return false;
305 }
@ autumn_roll
Definition: treatment.h:38

References autumn_roll, DO_IT_PROB, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

◆ AutumnSow()

bool Farm::AutumnSow ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a sowing event in the autumn on a_field.

365 {
366 
367  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
368  a_field->Trace( autumn_sow );
369  a_field->SetLastTreatment( autumn_sow );
370  a_field->SetGrowthPhase( sow );
371  a_field->SetLastSownVeg(a_field->GetVegType());
372  // Reduce the vegetation to zero
373  a_field->ZeroVeg();
374  int pref=a_field->GetUnsprayedMarginPolyRef();
375  if (pref!=-1){
376  // Must have an unsprayed margin so need to pass the information on to it
377  LE* um=g_landscape_p->SupplyLEPointer(pref);
379  um->SetGrowthPhase( sow );
380  um->ZeroVeg();
381  um->SetLastSownVeg(um->GetVegType());
382  }
383  return true;
384  }
385  return false;
386 }
virtual void SetGrowthPhase(int)
Definition: elements.h:170
void SetLastSownVeg(TTypesOfVegetation a_tov)
Records the last vegetation type to be sown.
Definition: elements.h:293
virtual TTypesOfVegetation GetVegType(void)
Definition: elements.h:125
@ sow
Definition: plants.h:53
@ autumn_sow
Definition: treatment.h:41

References autumn_sow, DO_IT_PROB, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::GetVegType(), Weather::Raining(), LE::SetGrowthPhase(), LE::SetLastSownVeg(), LE::SetLastTreatment(), sow, Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

◆ BedForming()

bool Farm::BedForming ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Do bed forming up on a_field, probably of carrots.

1691 {
1692 
1693  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1694  a_field->Trace(bed_forming);
1695  a_field->SetLastTreatment(bed_forming);
1696  a_field->InsectMortality(0.75);
1697  a_field->ZeroVeg();
1699  int pref = a_field->GetUnsprayedMarginPolyRef();
1700  if (pref != -1) {
1701  // Must have an unsprayed margin so need to pass the information on to it
1702  LE* um = g_landscape_p->SupplyLEPointer(pref);
1704  um->ZeroVeg();
1705  um->InsectMortality(0.75);
1707  }
1708  return true;
1709  }
1710  return false;
1711 }
void SetTramlinesDecay(int a_decaytime_days)
Definition: elements.h:310
#define EL_TRAMLINE_DECAYTIME
Definition: elements.h:57
@ bed_forming
Definition: treatment.h:106

References bed_forming, DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

◆ Biocide()

bool Farm::Biocide ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Biocide applied on a_field.

2416 {
2417  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2418  a_field->Trace(biocide);
2419  a_field->SetLastTreatment(biocide);
2421  int pref = a_field->GetUnsprayedMarginPolyRef();
2422  if (pref != -1) {
2423  // Must have an unsprayed margin so need to pass the information on to it
2424  LE* um = g_landscape_p->SupplyLEPointer(pref);
2427  }
2428  return true;
2429  }
2430  return false;
2431 }
@ biocide
Definition: treatment.h:104

References biocide, DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ BulbHarvest()

bool Farm::BulbHarvest ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a bulb harvest on a_field.

2466 {
2467  //5 days good weather before
2468  if ((0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(), 5) < 0.1) && DoIt(DO_IT_PROB))) {
2469  a_field->Trace(bulb_harvest);
2470  a_field->SetLastTreatment(bulb_harvest);
2471  a_field->SetGrowthPhase(harvest1);
2472  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
2473  a_field->InsectMortality(0.3);
2474  // remove all vegetation
2475  a_field->ZeroVeg();
2476  double insects = a_field->GetInsectPop();
2477  a_field->ResetDigestability();
2478  a_field->RecalculateBugsNStuff();
2479  a_field->SetInsectPop(insects);
2481  int pref = a_field->GetUnsprayedMarginPolyRef();
2482  if (pref != -1) {
2483  // Must have an unsprayed margin so need to pass the information on to it
2484  LE* um = g_landscape_p->SupplyLEPointer(pref);
2486  um->SetGrowthPhase(harvest1);
2487  um->InsectMortality(0.3);
2488  um->ZeroVeg();
2490  um->ResetDigestability();
2491  um->RecalculateBugsNStuff();
2492  }
2493  return true;
2494  }
2495  return false;
2496 }
class Calendar * g_date
Definition: calendar.cpp:38
long Date(void)
Definition: calendar.h:57
virtual void RecalculateBugsNStuff(void)
Definition: elements.h:132
virtual void ResetDigestability()
sets growth record to zero in descendent classes
Definition: elements.h:382
virtual double GetInsectPop(void)
Definition: elements.h:156
virtual void SetInsectPop(double)
Definition: elements.h:157
double GetRainPeriod(long a_date, unsigned int a_period)
Definition: weather.cpp:253
@ harvest1
Definition: plants.h:55
@ bulb_harvest
Definition: treatment.h:110

References bulb_harvest, Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_landscape_p, g_weather, LE::GetInsectPop(), Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), LE::RecalculateBugsNStuff(), LE::ResetDigestability(), LE::SetGrowthPhase(), LE::SetInsectPop(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

◆ BurnStrawStubble()

bool Farm::BurnStrawStubble ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Burn stubble on a_field.

2237 {
2238 
2239  if ( (0 >= a_days) && (g_weather->GetRainPeriod(g_date->Date(),3)>0.1))
2240  {
2241  return true;
2242  }
2243  if ( (0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(),3)<0.1)
2244  && DoIt(DO_IT_PROB)))
2245  {
2246  a_field->Trace( burn_straw_stubble );
2248  a_field->InsectMortality( 0.4 );
2249  a_field->ReduceVeg( 0.2 );
2251  int pref=a_field->GetUnsprayedMarginPolyRef();
2252  if (pref!=-1){
2253  // Must have an unsprayed margin so need to pass the information on to it
2254  LE* um=g_landscape_p->SupplyLEPointer(pref);
2256  um->ReduceVeg( 0.2 );
2257  um->InsectMortality( 0.4 );
2259  }
2260  return true;
2261  }
2262  return false;
2263 }
virtual void ReduceVeg(double)
Definition: elements.h:175
@ burn_straw_stubble
Definition: treatment.h:92

References burn_straw_stubble, Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_landscape_p, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), LE::ReduceVeg(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ CattleIsOut()

bool Farm::CattleIsOut ( LE a_field,
double  a_user,
int  a_days,
int  a_max 
)
virtual

Generate a 'cattle_out' event for every day the cattle are on a_field.

This is the main grazing method and as such is called by all grazed field management plans each day the cattle are out.

1975 {
1979  double biomass = a_field->GetVegBiomass();
1980  if (biomass > 100.0)
1981  {
1982  a_field->SetLastTreatment(cattle_out);
1983  a_field->Trace(cattle_out);
1984  // Reduce the vegetation because of grazing
1985  //double h=a_field->GetVegHeight();
1986  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1987  //a_field->ReduceVeg_Extended( reduc );
1988  a_field->GrazeVegetation( l_farm_cattle_veg_reduce.value( ), false );
1989  int pref = a_field->GetUnsprayedMarginPolyRef();
1990  if (pref != -1)
1991  {
1992  // Must have an unsprayed margin so need to pass the information on to it
1993  LE* um = g_landscape_p->SupplyLEPointer(pref);
1996  }
1997  }
1998  int d1 = g_date->DayInYear(10, 9);
1999  if (d1 > a_max) d1 = a_max;
2000  if ((((g_date->DayInYear() > d1) && (10 >= a_days)) && DoIt(10)) || (0 >= a_days))
2001  {
2002  a_field->ToggleCattleGrazing();
2003  int pref = a_field->GetUnsprayedMarginPolyRef();
2004  if (pref != -1){
2005  // Must have an unsprayed margin so need to pass the information on to it
2006  LE* um = g_landscape_p->SupplyLEPointer(pref);
2007  um->ToggleCattleGrazing();
2008  }
2009  return true;
2010  }
2011  return false;
2012 }
int DayInYear(void)
Definition: calendar.h:58
double value(void)
Definition: configurator.h:118
virtual void GrazeVegetation(double, bool)
Definition: elements.h:231
virtual double GetVegBiomass(void)
Definition: elements.h:154
virtual void ToggleCattleGrazing(void)
Definition: elements.h:161
static CfgFloat l_farm_cattle_veg_reduce("FARM_CATTLE_VEG_REDUCE", CFG_CUSTOM, 1.5)
@ cattle_out
Definition: treatment.h:83

References cattle_out, Calendar::DayInYear(), g_date, g_landscape_p, LE::GetUnsprayedMarginPolyRef(), LE::GetVegBiomass(), LE::GrazeVegetation(), l_farm_cattle_veg_reduce, LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::ToggleCattleGrazing(), LE::Trace(), and CfgFloat::value().

◆ CattleIsOutLow()

bool Farm::CattleIsOutLow ( LE a_field,
double  a_user,
int  a_days,
int  a_max 
)
virtual

Generate a 'cattle_out_low' event for every day the cattle are on a_field.

2019 {
2020 
2021  // Generate a 'cattle_in_out' event for every day the cattle is on the
2022  // field.
2023  double biomass = a_field->GetVegBiomass();
2024  if (biomass > 100.0)
2025  {
2026  a_field->SetLastTreatment(cattle_out_low);
2027  a_field->Trace(cattle_out_low);
2028  // Reduce the vegetation because of grazing
2029  //double h=a_field->GetVegHeight();
2030  //double reduc = 1-(l_farm_cattle_veg_reduce2.value()*((h-15)/15));
2031  //a_field->ReduceVeg_Extended( reduc );
2032  a_field->GrazeVegetation( l_farm_cattle_veg_reduce2.value( ), false );
2033  int pref = a_field->GetUnsprayedMarginPolyRef();
2034  if (pref != -1)
2035  {
2036  // Must have an unsprayed margin so need to pass the information on to it
2037  LE* um = g_landscape_p->SupplyLEPointer(pref);
2040  }
2041  }
2042  int d1 = g_date->DayInYear(10, 9);
2043  if (d1 > a_max) d1 = a_max;
2044  if ((((g_date->DayInYear() > d1) && (10 >= a_days)) && DoIt(10)) || (0 >= a_days))
2045  {
2046  a_field->ToggleCattleGrazing();
2047  int pref = a_field->GetUnsprayedMarginPolyRef();
2048  if (pref != -1){
2049  // Must have an unsprayed margin so need to pass the information on to it
2050  LE* um = g_landscape_p->SupplyLEPointer(pref);
2051  um->ToggleCattleGrazing();
2052  }
2053  return true;
2054  }
2055  return false;
2056 }
static CfgFloat l_farm_cattle_veg_reduce2("FARM_CATTLE_VEG_REDUCE_LOW", CFG_CUSTOM, 1.00)
@ cattle_out_low
Definition: treatment.h:100

References cattle_out_low, Calendar::DayInYear(), g_date, g_landscape_p, LE::GetUnsprayedMarginPolyRef(), LE::GetVegBiomass(), LE::GrazeVegetation(), l_farm_cattle_veg_reduce2, LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::ToggleCattleGrazing(), LE::Trace(), and CfgFloat::value().

◆ CattleOut()

bool Farm::CattleOut ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Start a grazing event on a_field today.

This is the main initiate grazing method and as such is called by all grazed field management plans at the moment cattle are put out.

1911 {
1915  if ((0 >= a_days) || DoIt( DO_IT_PROB ))
1916  {
1917  a_field->ToggleCattleGrazing();
1918  a_field->Trace( cattle_out );
1919  a_field->SetLastTreatment( cattle_out );
1920  // Reduce the vegetation because of grazing
1921  //double h=a_field->GetVegHeight();
1922  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1923  //a_field->ReduceVeg_Extended( reduc );
1924  a_field->GrazeVegetation( l_farm_cattle_veg_reduce.value(), false );
1925  int pref = a_field->GetUnsprayedMarginPolyRef();
1926  if (pref != -1)
1927  {
1928  // Must have an unsprayed margin so need to pass the information on to it
1929  // This happens if all arable fields are given unsprayed margins - they have no effect on grass unless it is sprayed with pesticides
1930  LE* um = g_landscape_p->SupplyLEPointer( pref );
1931  um->ToggleCattleGrazing();
1934  }
1935  return true;
1936  }
1937  return false;
1938 }

References cattle_out, DO_IT_PROB, g_landscape_p, LE::GetUnsprayedMarginPolyRef(), LE::GrazeVegetation(), l_farm_cattle_veg_reduce, LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::ToggleCattleGrazing(), LE::Trace(), and CfgFloat::value().

◆ CattleOutLowGrazing()

bool Farm::CattleOutLowGrazing ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Start a extensive grazing event on a_field today.

1945 {
1946 
1947  if ( (0 >= a_days)|| DoIt(DO_IT_PROB)) {
1948  a_field->ToggleCattleGrazing();
1949  a_field->Trace( cattle_out_low );
1950  a_field->SetLastTreatment( cattle_out_low );
1951  // Reduce the vegetation because of grazing
1952  //double h=a_field->GetVegHeight();
1953  //double reduc = 1-(l_farm_cattle_veg_reduce.value()*((h-15)/15));
1954  //a_field->ReduceVeg_Extended( reduc );
1955  a_field->GrazeVegetation( l_farm_cattle_veg_reduce2.value( ), false );
1956  int pref=a_field->GetUnsprayedMarginPolyRef();
1957  if (pref!=-1){
1958  // Must have an unsprayed margin so need to pass the information on to it
1959  // This happens if all arable fields are given unsprayed margins - they have no effect on grass unless it is sprayed with pesticides
1960  LE* um=g_landscape_p->SupplyLEPointer(pref);
1961  um->ToggleCattleGrazing();
1964  }
1965  return true;
1966  }
1967  return false;
1968 }

References cattle_out_low, DO_IT_PROB, g_landscape_p, LE::GetUnsprayedMarginPolyRef(), LE::GrazeVegetation(), l_farm_cattle_veg_reduce2, LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::ToggleCattleGrazing(), LE::Trace(), and CfgFloat::value().

◆ Centroids()

void Farm::Centroids ( )

Finds farm's centroids - x and y.

Calculate a farm's centroid as an average of its fields' centroids.

5334  {
5337  int sum_centroidx = 0;
5338  int sum_centroidy = 0;
5339  int no_fields = (int)m_fields.size();
5340  for (int i=0; i<no_fields; i++){
5341  sum_centroidx += m_fields[i]->GetCentroidX();
5342  sum_centroidy += m_fields[i]->GetCentroidY();
5343  }
5344  m_farm_centroidx = sum_centroidx/no_fields;
5345  m_farm_centroidy = sum_centroidy/no_fields;
5346 }
int m_farm_centroidy
Farm's centroid, value y. Equal to the average of the y centroid values of all farm's fields.
Definition: farm.h:961
int m_farm_centroidx
Farm's centroid, value x. Equal to the average of the x centroid values of all farm's fields.
Definition: farm.h:959

References m_farm_centroidx, m_farm_centroidy, and m_fields.

Referenced by FarmManager::FindNeighbours().

◆ CheckRotationManagementLoop()

void Farm::CheckRotationManagementLoop ( FarmEvent ev)
protected

Rotation error check function

839  {
840  if ( ev->m_field->GetMgtLoopDetectDate() == g_date->Date() ) {
841  // The last crop managment plan stopped on the same day as
842  // it was started.
843 
844  // Bump loop counter.
846 
847  if ( ev->m_field->GetMgtLoopDetectCount() > ( long )( m_rotation.size() + 2 ) ) {
848  // We have a loop.
849  char errornum[ 20 ];
850  sprintf( errornum, "%d", m_farmtype );
851  g_msg->Warn( WARN_BUG, "Rotation management loop detected in farmtype ", errornum );
852  exit( 1 );
853  }
854  } else {
855  ev->m_field->SetMgtLoopDetectCount( 0 );
856  }
857 }
TTypesOfFarm m_farmtype
Definition: farm.h:940
void SetMgtLoopDetectCount(long a_num)
Definition: elements.h:122
long GetMgtLoopDetectDate(void)
Definition: elements.h:119
long GetMgtLoopDetectCount(void)
Definition: elements.h:121
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
class MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
@ WARN_BUG
Definition: maperrormsg.h:34
LE * m_field
Definition: farm.h:472

References Calendar::Date(), g_date, g_msg, LE::GetMgtLoopDetectCount(), LE::GetMgtLoopDetectDate(), FarmEvent::m_field, LE::SetMgtLoopDetectCount(), MapErrorMsg::Warn(), and WARN_BUG.

◆ CutOrch()

bool Farm::CutOrch ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Cut vegetation on orchard crop. //based on cut to silage - values from cutting function of orchard.

2363 {
2364 
2365  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2366  a_field->Trace( mow ); //? tried to do=mow...
2367  a_field->SetLastTreatment( mow );
2368  a_field->SetMownDecay( 12 ); // 12 days of not suitable
2369  //ReduceVeg_Extended( 0.2 );
2370  //a_field->InsectMortality( 0.4 );
2371  a_field->SetGrowthPhase( harvest1 );
2372  //m_DateCut = a_today; ?? what to substitute it with?
2373 
2374  a_field->SetVegParameters( l_el_o_cut_height.value(), l_el_o_cut_total.value(), l_el_o_cut_green.value(), 0 ); //is 0 ok for weed biomass
2375 
2376  int pref=a_field->GetUnsprayedMarginPolyRef();
2377  if (pref!=-1){
2378  // Must have an unsprayed margin so need to pass the information on to it
2379  LE* um=g_landscape_p->SupplyLEPointer(pref);
2380  um->SetLastTreatment( mow );
2381  um->ReduceVeg_Extended( 0.2 ); //are these values ok?
2382  um->InsectMortality( 0.4 );
2384  }
2385  return true;
2386  }
2387  return false;
2388 }
void SetMownDecay(int a_decaytime_days)
Definition: elements.h:314
virtual void ReduceVeg_Extended(double)
Definition: elements.h:176
virtual void SetVegParameters(double, double, double, double)
Definition: elements.h:166
CfgFloat l_el_o_cut_total
CfgFloat l_el_o_cut_height
CfgFloat l_el_o_cut_green
@ mow
Definition: treatment.h:93

References DO_IT_PROB, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), l_el_o_cut_green, l_el_o_cut_height, l_el_o_cut_total, mow, Weather::Raining(), LE::ReduceVeg_Extended(), LE::SetGrowthPhase(), LE::SetLastTreatment(), LE::SetMownDecay(), LE::SetVegParameters(), Landscape::SupplyLEPointer(), LE::Trace(), and CfgFloat::value().

◆ CutToHay()

bool Farm::CutToHay ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay cutting on a_field.

2270 {
2271 
2272  if ( (0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1)
2273  && DoIt(DO_IT_PROB)))
2274  {
2275  a_field->Trace( cut_to_hay );
2276  a_field->SetLastTreatment( cut_to_hay );
2277  a_field->SetGrowthPhase(harvest1);
2278  a_field->InsectMortality(0.4);
2279  a_field->ReduceVeg_Extended( 0.2 );
2280  a_field->SetVegHeight(10);
2281  //a_field->ResetDigestability();
2283  int pref=a_field->GetUnsprayedMarginPolyRef();
2284  if (pref!=-1){
2285  // Must have an unsprayed margin so need to pass the information on to it
2286  LE* um=g_landscape_p->SupplyLEPointer(pref);
2288  um->SetGrowthPhase(harvest1);
2289  um->InsectMortality(0.4);
2290  um->ReduceVeg_Extended( 0.2 );
2291  um->SetVegHeight( 10);
2293  }
2294  return true;
2295  }
2296  return false;
2297 }
virtual void SetVegHeight(double)
Definition: elements.h:165
@ cut_to_hay
Definition: treatment.h:85

References cut_to_hay, Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_landscape_p, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), LE::ReduceVeg_Extended(), LE::SetGrowthPhase(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::SetVegHeight(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ CutToSilage()

bool Farm::CutToSilage ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Cut vegetation for silage on a_field.

2330 {
2331 
2332  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2333  a_field->Trace( cut_to_silage );
2334  a_field->SetLastTreatment( cut_to_silage );
2335  a_field->ReduceVeg_Extended( 0.2 );
2336  a_field->InsectMortality( 0.4 );
2337  a_field->SetVegHeight( 10 );
2339  a_field->SetGrowthPhase(harvest1);
2340  //a_field->ResetDigestability();
2341  int pref=a_field->GetUnsprayedMarginPolyRef();
2342  if (pref!=-1){
2343  // Must have an unsprayed margin so need to pass the information on to it
2344  LE* um=g_landscape_p->SupplyLEPointer(pref);
2346  um->ReduceVeg_Extended( 0.2 );
2347  um->InsectMortality( 0.4 );
2348  um->SetVegHeight( 10 );
2350  um->ResetDigestability();
2351  um->SetGrowthPhase(harvest1);
2352  }
2353  return true;
2354  }
2355  return false;
2356 }
@ cut_to_silage
Definition: treatment.h:86

References cut_to_silage, DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), Weather::Raining(), LE::ReduceVeg_Extended(), LE::ResetDigestability(), LE::SetGrowthPhase(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::SetVegHeight(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ CutWeeds()

bool Farm::CutWeeds ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out weed topping on a_field.

2304 {
2305 
2306  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB)))
2307  {
2308  a_field->Trace( cut_weeds );
2309  a_field->SetLastTreatment( cut_weeds );
2310  a_field->ReduceVeg( 0.8 );
2312  int pref=a_field->GetUnsprayedMarginPolyRef();
2313  if (pref!=-1){
2314  // Must have an unsprayed margin so need to pass the information on to it
2315  LE* um=g_landscape_p->SupplyLEPointer(pref);
2316  um->SetLastTreatment( cut_weeds );
2317  um->ReduceVeg( 0.8 );
2319  }
2320  return true;
2321  }
2322  return false;
2323 }
@ cut_weeds
Definition: treatment.h:94

References cut_weeds, DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::ReduceVeg(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ DeepPlough()

bool Farm::DeepPlough ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a deep ploughing event on a_field.

418 {
419 
420  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
421  a_field->Trace( deep_ploughing );
422  a_field->SetLastTreatment( deep_ploughing );
423  // Apply 90% mortality to the insects
424  a_field->InsectMortality( 0.1 );
425  // Reduce the vegetation to zero
426  a_field->ZeroVeg();
427  int pref=a_field->GetUnsprayedMarginPolyRef();
428  if (pref!=-1){
429  // Must have an unsprayed margin so need to pass the information on to it
430  LE* um=g_landscape_p->SupplyLEPointer(pref);
432  um->InsectMortality( 0.1 );
433  um->ZeroVeg();
434  }
435  return true;
436  }
437  return false;
438 }
@ deep_ploughing
Definition: treatment.h:43

References deep_ploughing, DO_IT_PROB, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

◆ DoIt()

bool Farm::DoIt ( double  a_probability)

Return chance out of 0 to 100.

800  {
801  return (g_rand_uni() < (a_probability/100.0));
802 }
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni

References g_rand_uni.

◆ DoIt_prob()

bool Farm::DoIt_prob ( double  a_probability)

Return chance out of 0 to 1.

808  {
809  return (g_rand_uni() < a_probability);
810 }

References g_rand_uni.

◆ FA_AmmoniumSulphate()

bool Farm::FA_AmmoniumSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply ammonium sulphate to a_field owned by an stock farmer.

991 {
992 
993  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
994  a_field->Trace( fa_ammoniumsulphate );
997  int pref=a_field->GetUnsprayedMarginPolyRef();
998  if (pref!=-1){
999  // Must have an unsprayed margin so need to pass the information on to it
1000  LE* um=g_landscape_p->SupplyLEPointer(pref);
1003  }
1004  return true;
1005  }
1006  return false;
1007 }
@ fa_ammoniumsulphate
Definition: treatment.h:65

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_ammoniumsulphate, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_Calcium()

bool Farm::FA_Calcium ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Calcium applied on a_field owned by a stock farmer.

1134 {
1135  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1136  a_field->Trace(fa_calcium);
1137  a_field->SetLastTreatment(fa_calcium);
1139  int pref = a_field->GetUnsprayedMarginPolyRef();
1140  if (pref != -1) {
1141  // Must have an unsprayed margin so need to pass the information on to it
1142  LE* um = g_landscape_p->SupplyLEPointer(pref);
1145  }
1146  return true;
1147  }
1148  return false;
1149 }
@ fa_calcium
Definition: treatment.h:70

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_calcium, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_GreenManure()

bool Farm::FA_GreenManure ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread green manure on a_field owned by an stock farmer.

1063 {
1064 
1065  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1066  a_field->Trace( fa_greenmanure );
1067  a_field->SetLastTreatment( fa_greenmanure );
1069  int pref=a_field->GetUnsprayedMarginPolyRef();
1070  if (pref!=-1){
1071  // Must have an unsprayed margin so need to pass the information on to it
1072  LE* um=g_landscape_p->SupplyLEPointer(pref);
1075  }
1076  return true;
1077  }
1078  return false;
1079 }
@ fa_greenmanure
Definition: treatment.h:67

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_greenmanure, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_ManganeseSulphate()

bool Farm::FA_ManganeseSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply manganese sulphate to a_field owned by an stock farmer.

1014 {
1015  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1016  a_field->Trace(fa_manganesesulphate);
1019  int pref = a_field->GetUnsprayedMarginPolyRef();
1020  if (pref != -1) {
1021  // Must have an unsprayed margin so need to pass the information on to it
1022  LE* um = g_landscape_p->SupplyLEPointer(pref);
1025  }
1026  return true;
1027  }
1028  return false;
1029 }
@ fa_manganesesulphate
Definition: treatment.h:64

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_manganesesulphate, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_Manure()

bool Farm::FA_Manure ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread manure on a_field owned by an stock farmer.

1037 {
1038 
1039  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
1040  !g_weather->Raining() && DoIt(DO_IT_PROB)))
1041 {
1042  a_field->Trace( fa_manure );
1043  a_field->SetLastTreatment( fa_manure );
1045  int pref=a_field->GetUnsprayedMarginPolyRef();
1046  if (pref!=-1){
1047  // Must have an unsprayed margin so need to pass the information on to it
1048  LE* um=g_landscape_p->SupplyLEPointer(pref);
1049  um->SetLastTreatment( fa_manure );
1051  }
1052  return true;
1053  }
1054  return false;
1055 }
double GetTemp(long a_date)
Get the temperature on a particular date.
Definition: weather.h:417
@ fa_manure
Definition: treatment.h:66

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_manure, g_landscape_p, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_NPK()

bool Farm::FA_NPK ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply NPK fertilizer to a_field owned by an stock farmer.

918 {
919 
920  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
921  a_field->Trace( fa_npk );
922  a_field->SetLastTreatment( fa_npk );
924  int pref=a_field->GetUnsprayedMarginPolyRef();
925  if (pref!=-1){
926  // Must have an unsprayed margin so need to pass the information on to it
927  LE* um=g_landscape_p->SupplyLEPointer(pref);
928  um->SetLastTreatment( fa_npk );
930  }
931  return true;
932  }
933  return false;
934 }
@ fa_npk
Definition: treatment.h:61

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_npk, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_NPKS()

bool Farm::FA_NPKS ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply NPKS fertilizer, on a_field owned by a stock farmer.

892 {
893 
894  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
895  a_field->Trace(fa_npks);
896  a_field->SetLastTreatment(fa_npks);
898  int pref = a_field->GetUnsprayedMarginPolyRef();
899  if (pref != -1) {
900  // Must have an unsprayed margin so need to pass the information on to it
901  LE* um = g_landscape_p->SupplyLEPointer(pref);
904  um->InsectMortality(0.4);
906  }
907 
908  return true;
909  }
910  return false;
911 }
@ sleep_all_day
Definition: treatment.h:33
@ fa_npks
Definition: treatment.h:60

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_npks, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), Weather::Raining(), LE::SetGrowthPhase(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), sleep_all_day, Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_PK()

bool Farm::FA_PK ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply PK fertilizer to a_field owned by an stock farmer.

942 {
943 
944  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
945  a_field->Trace( fa_pk );
946  a_field->SetLastTreatment( fa_pk );
948  int pref=a_field->GetUnsprayedMarginPolyRef();
949  if (pref!=-1){
950  // Must have an unsprayed margin so need to pass the information on to it
951  LE* um=g_landscape_p->SupplyLEPointer(pref);
952  um->SetLastTreatment( fa_pk );
954  }
955  return true;
956  }
957  return false;
958 }
@ fa_pk
Definition: treatment.h:62

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_pk, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_RSM()

bool Farm::FA_RSM ( LE a_field,
double  a_user,
int  a_days 
)
virtual

RSM (ammonium nitrate solution) applied on a_field owned by a stock farmer.

1112 {
1113  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1114  a_field->Trace(fa_rsm);
1115  a_field->SetLastTreatment(fa_rsm);
1117  int pref = a_field->GetUnsprayedMarginPolyRef();
1118  if (pref != -1) {
1119  // Must have an unsprayed margin so need to pass the information on to it
1120  LE* um = g_landscape_p->SupplyLEPointer(pref);
1121  um->SetLastTreatment(fa_rsm);
1123  }
1124  return true;
1125  }
1126  return false;
1127 }
@ fa_rsm
Definition: treatment.h:69

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_rsm, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_Sludge()

bool Farm::FA_Sludge ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread sewege sludge on a_field owned by an stock farmer.

1087 {
1088 
1089  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
1090  !g_weather->Raining() && DoIt(DO_IT_PROB)))
1091 {
1092  a_field->Trace( fa_sludge );
1093  a_field->SetLastTreatment( fa_sludge );
1095  int pref=a_field->GetUnsprayedMarginPolyRef();
1096  if (pref!=-1){
1097  // Must have an unsprayed margin so need to pass the information on to it
1098  LE* um=g_landscape_p->SupplyLEPointer(pref);
1099  um->SetLastTreatment( fa_sludge );
1101  }
1102  return true;
1103  }
1104  return false;
1105 }
@ fa_sludge
Definition: treatment.h:68

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_sludge, g_landscape_p, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FA_Slurry()

bool Farm::FA_Slurry ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spready slurry on a_field owned by an stock farmer.

966 {
967 
968  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
969  !g_weather->Raining() && DoIt(DO_IT_PROB)))
970 {
971  a_field->Trace( fa_slurry );
972  a_field->SetLastTreatment( fa_slurry );
974  int pref=a_field->GetUnsprayedMarginPolyRef();
975  if (pref!=-1){
976  // Must have an unsprayed margin so need to pass the information on to it
977  LE* um=g_landscape_p->SupplyLEPointer(pref);
980  }
981  return true;
982  }
983  return false;
984 }
@ fa_slurry
Definition: treatment.h:63

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fa_slurry, g_landscape_p, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FlowerCutting()

bool Farm::FlowerCutting ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Flower cutting applied on a_field.

2438 {
2439  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
2440  a_field->Trace(flower_cutting);
2441  a_field->ReduceVeg_Extended(0.8);
2442  a_field->InsectMortality(0.9);
2443  a_field->SetVegHeight(35);
2444  a_field->SetLastTreatment(flower_cutting);
2446  int pref = a_field->GetUnsprayedMarginPolyRef();
2447  if (pref != -1) {
2448  // Must have an unsprayed margin so need to pass the information on to it
2449  LE* um = g_landscape_p->SupplyLEPointer(pref);
2450  um->ReduceVeg_Extended(0.8);
2451  um->InsectMortality(0.9);
2452  um->SetVegHeight(30);
2455  }
2456  return true;
2457  }
2458  return false;
2459 }
@ flower_cutting
Definition: treatment.h:109

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, flower_cutting, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), LE::InsectMortality(), Weather::Raining(), LE::ReduceVeg_Extended(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::SetVegHeight(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_AmmoniumSulphate()

bool Farm::FP_AmmoniumSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply Ammonium Sulphate to a_field owned by an arable farmer.

751 {
752 
753  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
754  a_field->Trace(fp_ammoniumsulphate);
757  int pref = a_field->GetUnsprayedMarginPolyRef();
758  if (pref != -1) {
759  // Must have an unsprayed margin so need to pass the information on to it
760  LE* um = g_landscape_p->SupplyLEPointer(pref);
763  }
764  return true;
765  }
766  return false;
767 }
@ fp_ammoniumsulphate
Definition: treatment.h:54

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_ammoniumsulphate, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_Calcium()

bool Farm::FP_Calcium ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Calcium applied on a_field owned by an arable farmer.

870 {
871  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
872  a_field->Trace(fp_calcium);
873  a_field->SetLastTreatment(fp_calcium);
875  int pref = a_field->GetUnsprayedMarginPolyRef();
876  if (pref != -1) {
877  // Must have an unsprayed margin so need to pass the information on to it
878  LE* um = g_landscape_p->SupplyLEPointer(pref);
881  }
882  return true;
883  }
884  return false;
885 }
@ fp_calcium
Definition: treatment.h:59

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_calcium, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_GreenManure()

bool Farm::FP_GreenManure ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread green manure on a_field owned by an arable farmer.

799 {
800 
801  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
802  a_field->Trace( fp_greenmanure );
803  a_field->SetLastTreatment( fp_greenmanure );
805  int pref=a_field->GetUnsprayedMarginPolyRef();
806  if (pref!=-1){
807  // Must have an unsprayed margin so need to pass the information on to it
808  LE* um=g_landscape_p->SupplyLEPointer(pref);
811  }
812  return true;
813  }
814  return false;
815 }
@ fp_greenmanure
Definition: treatment.h:56

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_greenmanure, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_LiquidNH3()

bool Farm::FP_LiquidNH3 ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply liquid ammonia fertilizer to a_field owned by an arable farmer.

678 {
679 
680  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
681  a_field->Trace( fp_liquidNH3 );
682  a_field->SetLastTreatment( fp_liquidNH3 );
684  int pref=a_field->GetUnsprayedMarginPolyRef();
685  if (pref!=-1){
686  // Must have an unsprayed margin so need to pass the information on to it
687  LE* um=g_landscape_p->SupplyLEPointer(pref);
690  }
691  return true;
692  }
693  return false;
694 }
@ fp_liquidNH3
Definition: treatment.h:51

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_liquidNH3, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_ManganeseSulphate()

bool Farm::FP_ManganeseSulphate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply Manganse Sulphate to a_field owned by an arable farmer.

728 {
729 
730  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
731  a_field->Trace( fp_manganesesulphate );
734  int pref=a_field->GetUnsprayedMarginPolyRef();
735  if (pref!=-1){
736  // Must have an unsprayed margin so need to pass the information on to it
737  LE* um=g_landscape_p->SupplyLEPointer(pref);
740  }
741  return true;
742  }
743  return false;
744 }
@ fp_manganesesulphate
Definition: treatment.h:53

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_manganesesulphate, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_Manure()

bool Farm::FP_Manure ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread manure on a_field owned by an arable farmer.

774 {
775 
776  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
777  !g_weather->Raining() && DoIt(DO_IT_PROB))) {
778  a_field->Trace( fp_manure );
779  a_field->SetLastTreatment( fp_manure );
781  int pref=a_field->GetUnsprayedMarginPolyRef();
782  if (pref!=-1){
783  // Must have an unsprayed margin so need to pass the information on to it
784  LE* um=g_landscape_p->SupplyLEPointer(pref);
787  }
788  return true;
789  }
790  return false;
791 }
@ fp_manure
Definition: treatment.h:55

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_manure, g_landscape_p, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_NPK()

bool Farm::FP_NPK ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply NPK fertilizer, on a_field owned by an arable farmer.

630 {
631 
632  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
633  a_field->Trace( fp_npk );
634  a_field->SetLastTreatment( fp_npk );
636  int pref=a_field->GetUnsprayedMarginPolyRef();
637  if (pref!=-1){
638  // Must have an unsprayed margin so need to pass the information on to it
639  LE* um=g_landscape_p->SupplyLEPointer(pref);
642  }
643  return true;
644  }
645  return false;
646 }
@ fp_npk
Definition: treatment.h:49

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_npk, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_NPKS()

bool Farm::FP_NPKS ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply NPKS fertilizer, on a_field owned by an arable farmer.

603 {
604 
605  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
606  a_field->Trace( fp_npks );
607  a_field->SetLastTreatment( fp_npks );
609  int pref=a_field->GetUnsprayedMarginPolyRef();
610 if (pref!=-1){
611  // Must have an unsprayed margin so need to pass the information on to it
612  LE* um=g_landscape_p->SupplyLEPointer(pref);
614  um->SetGrowthPhase( harvest1 );
615  um->InsectMortality( 0.4 );
617 }
618 
619  return true;
620  }
621  return false;
622 }
@ fp_npks
Definition: treatment.h:48

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_npks, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), harvest1, LE::InsectMortality(), Weather::Raining(), LE::SetGrowthPhase(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), sleep_all_day, Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_PK()

bool Farm::FP_PK ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply PK fertilizer, on a_field owned by an arable farmer.

654 {
655 
656  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
657  a_field->Trace( fp_pk );
658  a_field->SetLastTreatment( fp_pk );
660  int pref=a_field->GetUnsprayedMarginPolyRef();
661  if (pref!=-1){
662  // Must have an unsprayed margin so need to pass the information on to it
663  LE* um=g_landscape_p->SupplyLEPointer(pref);
664  um->SetLastTreatment(fp_pk);
666  }
667  return true;
668  }
669  return false;
670 }
@ fp_pk
Definition: treatment.h:50

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_pk, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_RSM()

bool Farm::FP_RSM ( LE a_field,
double  a_user,
int  a_days 
)
virtual

RSM (ammonium nitrate solution) applied on a_field owned by an arable farmer.

848 {
849  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
850  a_field->Trace(fp_rsm);
851  a_field->SetLastTreatment(fp_rsm);
853  int pref = a_field->GetUnsprayedMarginPolyRef();
854  if (pref != -1) {
855  // Must have an unsprayed margin so need to pass the information on to it
856  LE* um = g_landscape_p->SupplyLEPointer(pref);
859  }
860  return true;
861  }
862  return false;
863 }
@ fp_rsm
Definition: treatment.h:58

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_rsm, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_Sludge()

bool Farm::FP_Sludge ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Spread sewege on a_field owned by an arable farmer.

823 {
824  //
825  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
826  !g_weather->Raining() && DoIt(DO_IT_PROB)))
827 {
828  a_field->Trace( fp_sludge );
829  a_field->SetLastTreatment( fp_sludge );
831  int pref=a_field->GetUnsprayedMarginPolyRef();
832  if (pref!=-1){
833  // Must have an unsprayed margin so need to pass the information on to it
834  LE* um=g_landscape_p->SupplyLEPointer(pref);
837  }
838  return true;
839  }
840  return false;
841 }
@ fp_sludge
Definition: treatment.h:57

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_sludge, g_landscape_p, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FP_Slurry()

bool Farm::FP_Slurry ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply slurry to a_field owned by an arable farmer.

702 {
703 
704  if ( (0 >= a_days) || ((g_weather->GetTemp()>0)&&
705  !g_weather->Raining() && DoIt(DO_IT_PROB)))
706 {
707  a_field->Trace( fp_slurry );
708  a_field->SetLastTreatment( fp_slurry );
710  int pref=a_field->GetUnsprayedMarginPolyRef();
711  if (pref!=-1){
712  // Must have an unsprayed margin so need to pass the information on to it
713  LE* um=g_landscape_p->SupplyLEPointer(pref);
716  }
717  return true;
718  }
719  return false;
720 }
@ fp_slurry
Definition: treatment.h:52

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fp_slurry, g_landscape_p, g_weather, Weather::GetTemp(), LE::GetUnsprayedMarginPolyRef(), Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ FungicideTreat()

bool Farm::FungicideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply fungicide to a_field.

Reimplemented in OptimisingFarm.

1280 {
1281 
1282  if (0 >= a_days)
1283  {
1284  if ( ( ! a_field->GetSignal() & LE_SIG_NO_FUNGICIDE ))
1285  {
1286  a_field->Trace( fungicide_treat );
1287  a_field->SetLastTreatment( fungicide_treat );
1290  }
1291  return true;
1292  }
1293  else if ( (g_weather->GetWind()<4.5) &&
1294  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
1295  if ( ! (a_field->GetSignal() & LE_SIG_NO_FUNGICIDE) ) {
1296  a_field->Trace( fungicide_treat );
1297  a_field->SetLastTreatment( fungicide_treat );
1300  }
1301  return true;
1302  }
1303  return false;
1304 }
LE_Signal GetSignal(void)
Definition: elements.h:107
void CheckForPesticideRecord(LE *a_field, TTypesOfPesticideCategory a_pcide)
Check if needed and record pesticide application.
Definition: Landscape.cpp:669
double GetWind(long a_date)
Definition: weather.h:425
#define LE_SIG_NO_FUNGICIDE
Definition: elements.h:42
@ fungicide
Definition: landscape.h:63
@ fungicide_treat
Definition: treatment.h:73

References Landscape::CheckForPesticideRecord(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, fungicide, fungicide_treat, g_landscape_p, g_weather, LE::GetSignal(), Weather::GetWind(), LE_SIG_NO_FUNGICIDE, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), and LE::Trace().

◆ GetArea()

int Farm::GetArea ( void  )

Returns the area of arable fields owned by that farm.

1331  {
1332  int area = 0;
1333  for (unsigned int i = 0; i < m_fields.size(); i++) {
1334  if (m_fields[i]->GetElementType() == tole_Field) area += (int)m_fields[i]->GetArea();
1335  }
1336  return area;
1337 }
@ tole_Field
Definition: tole_declaration.h:43

References tole_Field.

Referenced by OptimisingFarm::ActualProfit(), AssignPermanentCrop(), FarmManager::DumpFarmAreas(), and OptimisingFarm::Match_crop_to_field().

◆ GetAreaDouble()

double Farm::GetAreaDouble ( void  )

Returns the area of arable fields owned by that farm.

1350  {
1351  double area = 0;
1352  for ( unsigned int i = 0; i < m_fields.size(); i++ ) {
1353  if (m_fields[i]->GetElementType()==tole_Field) area += m_fields[i]->GetArea();
1354  }
1355  return area;
1356 }

References tole_Field.

Referenced by OptimisingFarm::findTotalArea(), and FarmManager::Save_diff_farm_types_areas().

◆ GetAreaOpenFields()

int Farm::GetAreaOpenFields ( int  a_openness)

Returns the area of the fields above an openness of a_openness.

Returns the area of fields owned by that farm with an openness above a_openness

1370 {
1371  int area = 0;
1372  for (unsigned int i = 0; i < m_fields.size(); i++) {
1373  if (m_fields[i]->GetOpenness() > a_openness) area += int(m_fields[i]->GetArea());
1374  }
1375  return area;
1376 }

◆ GetCentroids()

APoint Farm::GetCentroids ( )
inline
908 { APoint pt; pt.m_x = m_farm_centroidx; pt.m_y = m_farm_centroidy; return pt; }
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:53
int m_y
Definition: ALMaSS_Setup.h:56
int m_x
Definition: ALMaSS_Setup.h:55

References m_farm_centroidx, m_farm_centroidy, APoint::m_x, and APoint::m_y.

◆ GetCrop()

TTypesOfVegetation Farm::GetCrop ( int  a_index)
inline
914  {
915  return m_rotation[a_index];
916  }

References m_rotation.

◆ GetFarmNumber()

int Farm::GetFarmNumber ( void  )
inline
782 { return m_farm_num; }
int m_farm_num
Definition: farm.h:944

References m_farm_num.

Referenced by FarmManager::FarmManagement(), InvIntPartition(), and Hunter_Population_Manager::SaveFarmHunters().

◆ GetFirstCropIndex()

int Farm::GetFirstCropIndex ( TTypesOfLandscapeElement  a_type)
protectedvirtual

Gets the first crop for the farm.

This method also synchronises farm rotations either within or between farms if needed. This is useful to try simple what if scenarios.

1385  {
1386  // If g_farm_fixed_rotation, then determine the first
1387  // crop number in the rotation rotation number.
1389 
1391  // We are running all the farms synchronized, so
1392  // simply set the first crop to run on all farm fields.
1393  return 0;
1394  }
1395 
1396  // Each farm runs its fields sync'ed but independently from
1397  // the other farmers.
1398 
1399  // Determine if this farm has selected its own start index
1400  // and set it if not. m_rotation_sync_index is initialized
1401  // to -1 by the Farm::Farm() constructor.
1402  if ( -1 == m_rotation_sync_index ) {
1403  m_rotation_sync_index = (int) (rand() % m_rotation.size());
1404  }
1405  // Return farm localized rotation index.
1406  return m_rotation_sync_index;
1407  }
1408 
1409  // Not synchronised, but we want to follow our rotation sequence, so check
1410  // if we have started this process, if not set the sync value.
1411  // afterwards just increment this.
1412  if ( -1 == m_rotation_sync_index ) {
1413  if (m_rotation.size() > 0) m_rotation_sync_index = (int)(rand() % m_rotation.size()); else m_rotation_sync_index = 0;
1414  }
1415  else m_rotation_sync_index = (int) ((m_rotation_sync_index+1) % m_rotation.size());
1416  return m_rotation_sync_index;
1417 }
bool value(void)
Definition: configurator.h:135
CfgBool g_farm_fixed_rotation_farms_async("FARM_FIXED_ROTATION_FARMS_ASYNC", CFG_CUSTOM, false)
CfgBool g_farm_fixed_rotation_enable("FARM_FIXED_ROTATION_ENABLE", CFG_CUSTOM, false)

References g_farm_fixed_rotation_enable, g_farm_fixed_rotation_farms_async, and CfgBool::value().

◆ GetFirstDate()

int Farm::GetFirstDate ( TTypesOfVegetation  a_tov)
protected

Gets the start date for a crop type.

1582  {
1583  switch (a_tov2) {
1584  case tov_Carrots:
1585  return m_carrots->GetFirstDate();
1586  case tov_BroadBeans:
1587  return m_broadbeans->GetFirstDate();
1588  case tov_FodderGrass:
1589  return m_foddergrass->GetFirstDate();
1591  return m_CGG1->GetFirstDate();
1593  return m_CGG2->GetFirstDate();
1594  case tov_FieldPeas:
1595  return m_fieldpeas->GetFirstDate();
1596  case tov_FieldPeasSilage:
1597  return m_fieldpeassilage->GetFirstDate();
1598  case tov_FodderBeet:
1599  return m_fodderbeet->GetFirstDate();
1600  case tov_SugarBeet:
1601  return m_sugarbeet->GetFirstDate();
1602  case tov_OFodderBeet:
1603  return m_ofodderbeet->GetFirstDate();
1604  case tov_Maize:
1605  return m_maize->GetFirstDate();
1606  case tov_OMaizeSilage:
1607  return m_omaizesilage->GetFirstDate();
1608  case tov_MaizeSilage:
1609  return m_maizesilage->GetFirstDate();
1611  return m_OBarleyPCG->GetFirstDate();
1612  case tov_OCarrots:
1613  return m_ocarrots->GetFirstDate();
1615  return m_OCGG1->GetFirstDate();
1617  return m_OCGG2->GetFirstDate();
1619  return m_OCGS1->GetFirstDate();
1620  case tov_OFieldPeas:
1621  return m_ofieldpeas->GetFirstDate();
1622  case tov_OFirstYearDanger:
1623  return m_ofirstyeardanger->GetFirstDate();
1624  case tov_OGrazingPigs:
1625  return m_ograzingpigs->GetFirstDate();
1626  case tov_OrchardCrop:
1627  return m_orchardcrop->GetFirstDate();
1628  case tov_OOats:
1629  return m_ooats->GetFirstDate();
1630  case tov_Oats:
1631  return m_oats->GetFirstDate();
1633  return m_opermgrassgrazed->GetFirstDate();
1634  case tov_OPotatoes:
1635  return m_opotatoes->GetFirstDate();
1636  case tov_OSpringBarley:
1637  return m_ospringbarley->GetFirstDate();
1638  case tov_OSBarleySilage:
1639  return m_osbarleysilage->GetFirstDate();
1640  case tov_OSpringBarleyExt:
1641  return m_ospringbarleyext->GetFirstDate();
1642  case tov_OSpringBarleyPigs:
1643  return m_ospringbarleypigs->GetFirstDate();
1644  case tov_OWinterBarley:
1645  return m_owinterbarley->GetFirstDate();
1646  case tov_OWinterBarleyExt:
1647  return m_owinterbarleyext->GetFirstDate();
1648  case tov_OWinterRape:
1649  return m_owinterrape->GetFirstDate();
1650  case tov_OWinterRye:
1651  return m_owinterrye->GetFirstDate();
1653  return m_owinterwheatundersown->GetFirstDate();
1654  case tov_OWinterWheat:
1655  return m_owinterwheat->GetFirstDate();
1657  return m_owinterwheatundersownext->GetFirstDate();
1659  return m_permgrassgrazed->GetFirstDate();
1661  return m_permgrasslowyield->GetFirstDate();
1662  case tov_PermanentGrassTussocky: // Only used for tole_PermPastureTussocky
1663  return m_permgrasstussocky->GetFirstDate();
1664  case tov_PermanentSetaside:
1665  return m_permanentsetaside->GetFirstDate();
1666  case tov_Potatoes:
1667  return m_potatoes->GetFirstDate();
1668  case tov_SeedGrass1:
1669  return m_seedgrass1->GetFirstDate();
1670  case tov_SeedGrass2:
1671  return m_seedgrass2->GetFirstDate();
1672  case tov_Setaside:
1673  return m_setaside->GetFirstDate();
1674  case tov_SpringBarley:
1675  return m_springbarley->GetFirstDate();
1676  case tov_SpringBarleySpr:
1677  return m_springbarleyspr->GetFirstDate();
1679  return m_springbarleyptreatment->GetFirstDate();
1681  return m_springbarleyskmanagement->GetFirstDate();
1683  return m_sbarleyclovergrass->GetFirstDate();
1684  case tov_SpringBarleySeed:
1685  return m_springbarleyseed->GetFirstDate();
1687  return m_springbarleysilage->GetFirstDate();
1689  return m_springbarleystrigling->GetFirstDate();
1691  return m_springbarleystriglingsingle->GetFirstDate();
1693  return m_springbarleystriglingculm->GetFirstDate();
1694  case tov_SpringRape:
1695  return m_springrape->GetFirstDate();
1696  case tov_Triticale:
1697  return m_triticale->GetFirstDate();
1698  case tov_OTriticale:
1699  return m_otriticale->GetFirstDate();
1700  case tov_WinterBarley:
1701  return m_winterbarley->GetFirstDate();
1702  case tov_WinterRape:
1703  return m_winterrape->GetFirstDate();
1704  case tov_WinterRye:
1705  return m_winterrye->GetFirstDate();
1706  case tov_WinterWheat:
1707  return m_winterwheat->GetFirstDate();
1709  return m_winterwheatstrigling->GetFirstDate();
1711  return m_winterwheatstriglingsingle->GetFirstDate();
1713  return m_winterwheatstriglingculm->GetFirstDate();
1714  case tov_WWheatPControl:
1715  return m_wwheatpcontrol->GetFirstDate();
1717  return m_wwheatptoxiccontrol->GetFirstDate();
1718  case tov_WWheatPTreatment:
1719  return m_wwheatptreatment->GetFirstDate();
1721  return m_agrochemindustrycereal->GetFirstDate();
1722  case tov_YoungForest:
1723  return m_youngforest->GetFirstDate();
1724  case tov_NorwegianPotatoes:
1725  return m_norwegianpotatoes->GetFirstDate();
1726  case tov_NorwegianOats:
1727  return m_norwegianoats->GetFirstDate();
1729  return m_norwegianspringbarley->GetFirstDate();
1730 
1731  case tov_PLWinterWheat:
1732  return m_plwinterwheat->GetFirstDate();
1733  case tov_PLWinterRape:
1734  return m_plwinterrape->GetFirstDate();
1735  case tov_PLWinterBarley:
1736  return m_plwinterbarley->GetFirstDate();
1737  case tov_PLWinterTriticale:
1738  return m_plwintertriticale->GetFirstDate();
1739  case tov_PLWinterRye:
1740  return m_plwinterrye->GetFirstDate();
1741  case tov_PLSpringWheat:
1742  return m_plspringwheat->GetFirstDate();
1743  case tov_PLSpringBarley:
1744  return m_plspringbarley->GetFirstDate();
1745  case tov_PLMaize:
1746  return m_plmaize->GetFirstDate();
1747  case tov_PLMaizeSilage:
1748  return m_plmaizesilage->GetFirstDate();
1749  case tov_PLPotatoes:
1750  return m_plpotatoes->GetFirstDate();
1751  case tov_PLBeet:
1752  return m_plbeet->GetFirstDate();
1753  case tov_PLFodderLucerne1:
1754  return m_plfodderlucerne1->GetFirstDate();
1755  case tov_PLFodderLucerne2:
1756  return m_plfodderlucerne2->GetFirstDate();
1757  case tov_PLCarrots:
1758  return m_plcarrots->GetFirstDate();
1759  case tov_PLSpringBarleySpr:
1760  return m_plspringbarleyspr->GetFirstDate();
1761  case tov_PLWinterWheatLate:
1762  return m_plwinterwheatlate->GetFirstDate();
1763  case tov_PLBeetSpr:
1764  return m_plbeetspr->GetFirstDate();
1765  case tov_PLBeans:
1766  return m_plbeans->GetFirstDate();
1767 
1768  case tov_NLBeet:
1769  return m_nlbeet->GetFirstDate();
1770  case tov_NLCarrots:
1771  return m_nlcarrots->GetFirstDate();
1772  case tov_NLMaize:
1773  return m_nlmaize->GetFirstDate();
1774  case tov_NLPotatoes:
1775  return m_nlpotatoes->GetFirstDate();
1776  case tov_NLSpringBarley:
1777  return m_nlspringbarley->GetFirstDate();
1778  case tov_NLWinterWheat:
1779  return m_nlwinterwheat->GetFirstDate();
1780  case tov_NLCabbage:
1781  return m_nlcabbage->GetFirstDate();
1782  case tov_NLTulips:
1783  return m_nltulips->GetFirstDate();
1784  case tov_NLGrassGrazed1:
1785  return m_nlgrassgrazed1->GetFirstDate();
1787  return m_nlgrassgrazed1spring->GetFirstDate();
1788  case tov_NLGrassGrazed2:
1789  return m_nlgrassgrazed2->GetFirstDate();
1790  case tov_NLGrassGrazedLast:
1791  return m_nlgrassgrazedlast->GetFirstDate();
1793  return m_nlpermanentgrassgrazed->GetFirstDate();
1794  case tov_NLBeetSpring:
1795  return m_nlbeetspring->GetFirstDate();
1796  case tov_NLCarrotsSpring:
1797  return m_nlcarrotsspring->GetFirstDate();
1798  case tov_NLMaizeSpring:
1799  return m_nlmaizespring->GetFirstDate();
1800  case tov_NLPotatoesSpring:
1801  return m_nlpotatoesspring->GetFirstDate();
1803  return m_nlspringbarleyspring->GetFirstDate();
1804  case tov_NLCabbageSpring:
1805  return m_nlcabbagespring->GetFirstDate();
1806  case tov_NLCatchPeaCrop:
1807  return m_nlcatchpeacrop->GetFirstDate();
1808 
1810  return m_dummycroppesttesting->GetFirstDate();
1811 
1812  default:
1813  return 0;
1814  }
1815 }
@ tov_WWheatPControl
Definition: tov_declaration.h:55
@ tov_NLPotatoesSpring
Definition: tov_declaration.h:103
@ tov_OWinterWheatUndersown
Definition: tov_declaration.h:49
@ tov_BroadBeans
Definition: tov_declaration.h:66
@ tov_PLBeans
Definition: tov_declaration.h:87
@ tov_PermanentGrassGrazed
Definition: tov_declaration.h:49
@ tov_PLBeetSpr
Definition: tov_declaration.h:86
@ tov_NLSpringBarley
Definition: tov_declaration.h:93
@ tov_SpringBarleySKManagement
Definition: tov_declaration.h:65
@ tov_OFieldPeas
Definition: tov_declaration.h:43
@ tov_NLCarrots
Definition: tov_declaration.h:90
@ tov_NLGrassGrazedLast
Definition: tov_declaration.h:108
@ tov_SpringBarleyPTreatment
Definition: tov_declaration.h:63
@ tov_OWinterWheatUndersownExt
Definition: tov_declaration.h:63
@ tov_OSpringBarleyPigs
Definition: tov_declaration.h:47
@ tov_WWheatPTreatment
Definition: tov_declaration.h:55
@ tov_PermanentSetaside
Definition: tov_declaration.h:49
@ tov_WinterWheatStriglingCulm
Definition: tov_declaration.h:62
@ tov_DummyCropPestTesting
Definition: tov_declaration.h:112
@ tov_FodderGrass
Definition: tov_declaration.h:62
@ tov_SeedGrass1
Definition: tov_declaration.h:50
@ tov_OGrazingPigs
Definition: tov_declaration.h:44
@ tov_NLGrassGrazed1Spring
Definition: tov_declaration.h:107
@ tov_CloverGrassGrazed2
Definition: tov_declaration.h:33
@ tov_OSpringBarley
Definition: tov_declaration.h:46
@ tov_NLGrassGrazed2
Definition: tov_declaration.h:98
@ tov_PermanentGrassTussocky
Definition: tov_declaration.h:49
@ tov_OSpringBarleyExt
Definition: tov_declaration.h:63
@ tov_OFirstYearDanger
Definition: tov_declaration.h:44
@ tov_NLMaizeSpring
Definition: tov_declaration.h:102
@ tov_FieldPeasSilage
Definition: tov_declaration.h:65
@ tov_OWinterRape
Definition: tov_declaration.h:47
@ tov_OPotatoes
Definition: tov_declaration.h:44
@ tov_WinterRape
Definition: tov_declaration.h:53
@ tov_PLSpringBarley
Definition: tov_declaration.h:76
@ tov_OPermanentGrassGrazed
Definition: tov_declaration.h:44
@ tov_SpringBarley
Definition: tov_declaration.h:52
@ tov_OWinterBarley
Definition: tov_declaration.h:47
@ tov_NLBeetSpring
Definition: tov_declaration.h:100
@ tov_SpringBarleyStriglingSingle
Definition: tov_declaration.h:60
@ tov_PLPotatoes
Definition: tov_declaration.h:79
@ tov_NLCabbageSpring
Definition: tov_declaration.h:105
@ tov_SpringBarleySilage
Definition: tov_declaration.h:52
@ tov_PLCarrots
Definition: tov_declaration.h:83
@ tov_SpringBarleySeed
Definition: tov_declaration.h:52
@ tov_NLCabbage
Definition: tov_declaration.h:95
@ tov_NLCarrotsSpring
Definition: tov_declaration.h:101
@ tov_PLWinterBarley
Definition: tov_declaration.h:72
@ tov_SpringBarleyCloverGrass
Definition: tov_declaration.h:52
@ tov_Carrots
Definition: tov_declaration.h:31
@ tov_FieldPeas
Definition: tov_declaration.h:34
@ tov_WWheatPToxicControl
Definition: tov_declaration.h:55
@ tov_OTriticale
Definition: tov_declaration.h:47
@ tov_OMaizeSilage
Definition: tov_declaration.h:65
@ tov_PLWinterTriticale
Definition: tov_declaration.h:73
@ tov_Triticale
Definition: tov_declaration.h:53
@ tov_NorwegianOats
Definition: tov_declaration.h:68
@ tov_OFodderBeet
Definition: tov_declaration.h:65
@ tov_WinterWheat
Definition: tov_declaration.h:55
@ tov_OCarrots
Definition: tov_declaration.h:43
@ tov_OSBarleySilage
Definition: tov_declaration.h:56
@ tov_WinterWheatStrigling
Definition: tov_declaration.h:59
@ tov_SeedGrass2
Definition: tov_declaration.h:50
@ tov_PLMaizeSilage
Definition: tov_declaration.h:78
@ tov_SugarBeet
Definition: tov_declaration.h:66
@ tov_NorwegianPotatoes
Definition: tov_declaration.h:68
@ tov_PermanentGrassLowYield
Definition: tov_declaration.h:63
@ tov_CloverGrassGrazed1
Definition: tov_declaration.h:32
@ tov_NLWinterWheat
Definition: tov_declaration.h:94
@ tov_SpringRape
Definition: tov_declaration.h:53
@ tov_SpringBarleySpr
Definition: tov_declaration.h:66
@ tov_NLPotatoes
Definition: tov_declaration.h:92
@ tov_PLFodderLucerne2
Definition: tov_declaration.h:82
@ tov_Oats
Definition: tov_declaration.h:40
@ tov_MaizeSilage
Definition: tov_declaration.h:62
@ tov_OBarleyPeaCloverGrass
Definition: tov_declaration.h:41
@ tov_SpringBarleyStriglingCulm
Definition: tov_declaration.h:62
@ tov_Maize
Definition: tov_declaration.h:36
@ tov_OCloverGrassSilage1
Definition: tov_declaration.h:43
@ tov_NLPermanentGrassGrazed
Definition: tov_declaration.h:99
@ tov_PLMaize
Definition: tov_declaration.h:77
@ tov_OCloverGrassGrazed2
Definition: tov_declaration.h:43
@ tov_Potatoes
Definition: tov_declaration.h:50
@ tov_NLSpringBarleySpring
Definition: tov_declaration.h:104
@ tov_PLSpringWheat
Definition: tov_declaration.h:75
@ tov_PLFodderLucerne1
Definition: tov_declaration.h:81
@ tov_Setaside
Definition: tov_declaration.h:50
@ tov_NLGrassGrazed1
Definition: tov_declaration.h:97
@ tov_OWinterWheat
Definition: tov_declaration.h:66
@ tov_OWinterBarleyExt
Definition: tov_declaration.h:65
@ tov_OWinterRye
Definition: tov_declaration.h:49
@ tov_OOats
Definition: tov_declaration.h:44
@ tov_OCloverGrassGrazed1
Definition: tov_declaration.h:43
@ tov_NLMaize
Definition: tov_declaration.h:91
@ tov_NLBeet
Definition: tov_declaration.h:89
@ tov_WinterRye
Definition: tov_declaration.h:55
@ tov_FodderBeet
Definition: tov_declaration.h:35
@ tov_NLTulips
Definition: tov_declaration.h:96
@ tov_WinterWheatStriglingSingle
Definition: tov_declaration.h:62
@ tov_PLWinterRye
Definition: tov_declaration.h:74
@ tov_PLWinterWheatLate
Definition: tov_declaration.h:85
@ tov_WinterBarley
Definition: tov_declaration.h:53
@ tov_NLCatchPeaCrop
Definition: tov_declaration.h:106
@ tov_PLWinterWheat
Definition: tov_declaration.h:70
@ tov_SpringBarleyStrigling
Definition: tov_declaration.h:58
@ tov_PLBeet
Definition: tov_declaration.h:80
@ tov_NorwegianSpringBarley
Definition: tov_declaration.h:68
@ tov_YoungForest
Definition: tov_declaration.h:60
@ tov_PLSpringBarleySpr
Definition: tov_declaration.h:84
@ tov_AgroChemIndustryCereal
Definition: tov_declaration.h:55
@ tov_OrchardCrop
Definition: tov_declaration.h:65
@ tov_PLWinterRape
Definition: tov_declaration.h:71

References tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_DummyCropPestTesting, tov_FieldPeas, tov_FieldPeasSilage, tov_FodderBeet, tov_FodderGrass, tov_Maize, tov_MaizeSilage, tov_NLBeet, tov_NLBeetSpring, tov_NLCabbage, tov_NLCabbageSpring, tov_NLCarrots, tov_NLCarrotsSpring, tov_NLCatchPeaCrop, tov_NLGrassGrazed1, tov_NLGrassGrazed1Spring, tov_NLGrassGrazed2, tov_NLGrassGrazedLast, tov_NLMaize, tov_NLMaizeSpring, tov_NLPermanentGrassGrazed, tov_NLPotatoes, tov_NLPotatoesSpring, tov_NLSpringBarley, tov_NLSpringBarleySpring, tov_NLTulips, tov_NLWinterWheat, tov_NorwegianOats, tov_NorwegianPotatoes, tov_NorwegianSpringBarley, tov_Oats, tov_OBarleyPeaCloverGrass, tov_OCarrots, tov_OCloverGrassGrazed1, tov_OCloverGrassGrazed2, tov_OCloverGrassSilage1, tov_OFieldPeas, tov_OFirstYearDanger, tov_OFodderBeet, tov_OGrazingPigs, tov_OMaizeSilage, tov_OOats, tov_OPermanentGrassGrazed, tov_OPotatoes, tov_OrchardCrop, tov_OSBarleySilage, tov_OSpringBarley, tov_OSpringBarleyExt, tov_OSpringBarleyPigs, tov_OTriticale, tov_OWinterBarley, tov_OWinterBarleyExt, tov_OWinterRape, tov_OWinterRye, tov_OWinterWheat, tov_OWinterWheatUndersown, tov_OWinterWheatUndersownExt, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_PLBeans, tov_PLBeet, tov_PLBeetSpr, tov_PLCarrots, tov_PLFodderLucerne1, tov_PLFodderLucerne2, tov_PLMaize, tov_PLMaizeSilage, tov_PLPotatoes, tov_PLSpringBarley, tov_PLSpringBarleySpr, tov_PLSpringWheat, tov_PLWinterBarley, tov_PLWinterRape, tov_PLWinterRye, tov_PLWinterTriticale, tov_PLWinterWheat, tov_PLWinterWheatLate, tov_Potatoes, tov_SeedGrass1, tov_SeedGrass2, tov_Setaside, tov_SpringBarley, tov_SpringBarleyCloverGrass, tov_SpringBarleyPTreatment, tov_SpringBarleySeed, tov_SpringBarleySilage, tov_SpringBarleySKManagement, tov_SpringBarleySpr, tov_SpringBarleyStrigling, tov_SpringBarleyStriglingCulm, tov_SpringBarleyStriglingSingle, tov_SpringRape, tov_SugarBeet, tov_Triticale, tov_WinterBarley, tov_WinterRape, tov_WinterRye, tov_WinterWheat, tov_WinterWheatStrigling, tov_WinterWheatStriglingCulm, tov_WinterWheatStriglingSingle, tov_WWheatPControl, tov_WWheatPToxicControl, tov_WWheatPTreatment, and tov_YoungForest.

◆ GetIntensity()

int Farm::GetIntensity ( void  )
inline
907 { return m_intensity; }

References m_intensity.

◆ GetMaxOpenness()

int Farm::GetMaxOpenness ( )
inline

Returns the maximum openness score of the fields.

803  {
804  int op = 0;
805  for (int i = 0; i < m_fields.size(); i++)
806  {
807  int openness = m_fields[i]->GetOpenness();
808  if (openness > op) op = openness;
809  }
810  return op;
811  }

References m_fields.

◆ GetNextCrop()

TTypesOfVegetation Farm::GetNextCrop ( int  a_index)
inline
917  {
918  int ind = a_index + 1;
919  if (ind >= (int)m_rotation.size()) ind = ind - (int)m_rotation.size();
920  return m_rotation[ind];
921  }

References m_rotation.

◆ GetNextCropIndex()

int Farm::GetNextCropIndex ( int  a_rot_index)
protectedvirtual

Returns the next crop in the rotation.

Also provides the possibility of over-riding rotations using configuration settings

1427  {
1429  // Rotation not enabled.
1430  return a_rot_index;
1431  }
1432 
1433  if ( a_rot_index == -1 )
1434  return -1;
1435 
1436  if ( ( unsigned int ) ( ++a_rot_index ) == m_rotation.size() ) //AM comm: the last crop was the last element of the vector - so go back to the element zero; otherwise just add 1 to the index
1437  a_rot_index = 0;
1438 
1439  return a_rot_index;
1440 }
CfgBool g_farm_enable_crop_rotation("FARM_ENABLE_CROP_ROTATION", CFG_CUSTOM, true)

References g_farm_enable_crop_rotation, and CfgBool::value().

◆ GetNextCropStartDate()

int Farm::GetNextCropStartDate ( LE a_field,
TTypesOfVegetation a_curr_veg 
)
protected

Returns the start date of the next crop in the rotation.

864  {
865  TTypesOfVegetation l_tov2;
866 
867  if ( a_field->GetRotIndex() < 0 || g_farm_fixed_crop_enable.value() //|| g_farm_test_crop.value()
868  ) {
869  l_tov2 = a_curr_veg; // don't do it if no rotation
870  } else {
871  l_tov2 = m_rotation[ GetNextCropIndex( a_field->GetRotIndex() ) ];
872  }
873  a_curr_veg = l_tov2;
874  return GetFirstDate( l_tov2 );
875 }
int GetFirstDate(TTypesOfVegetation a_tov)
Gets the start date for a crop type.
Definition: farm.cpp:1582
virtual int GetNextCropIndex(int a_rot_index)
Returns the next crop in the rotation.
Definition: farm.cpp:1427
int GetRotIndex(void)
Definition: elements.h:309
CfgBool g_farm_fixed_crop_enable("FARM_FIXED_CROP_ENABLE", CFG_CUSTOM, false)
TTypesOfVegetation
Definition: tov_declaration.h:30

References g_farm_fixed_crop_enable, LE::GetRotIndex(), and CfgBool::value().

◆ GetNoFields()

int Farm::GetNoFields ( )
inline

Returns the number of the fields owned.

794 { return (int) m_fields.size(); }

References m_fields.

◆ GetNoOpenFields()

int Farm::GetNoOpenFields ( int  a_openness)

Returns the number of the fields above an openness of a_openness.

Returns the number of fields owned by that farm with an openness above a_openness

1360 {
1361  int num = 0;
1362  for (unsigned int i = 0; i < m_fields.size(); i++) {
1363  if (m_fields[i]->GetOpenness() > a_openness) num++;
1364  }
1365  return num;
1366 }

◆ GetPreviousCrop()

TTypesOfVegetation Farm::GetPreviousCrop ( int  a_index)
inline
909  {
910  int ind = a_index - 1;
911  if (ind < 0) ind = (int)m_rotation.size() - 1;
912  return m_rotation[ind];
913  }

References m_rotation.

Referenced by Field::GetPreviousCrop().

◆ GetTotalArea()

int Farm::GetTotalArea ( void  )

Returns the area of all fields owned by that farm.

1340  {
1341  int area = 0;
1342  for (unsigned int i = 0; i < m_fields.size(); i++)
1343  {
1344  area += (int)m_fields[i]->GetArea();
1345  }
1346  return area;
1347 }

◆ GetType()

TTypesOfFarm Farm::GetType ( void  )
inline
901 { return m_farmtype; }

References m_farmtype.

◆ GetValidCoords()

APoint Farm::GetValidCoords ( )
inline

Returns the valid coordinates of the first field owned by a farm.

800 { APoint pt; pt.m_x = m_fields[0]->GetValidX(); pt.m_y = m_fields[0]->GetValidY(); return pt; }

References m_fields, APoint::m_x, and APoint::m_y.

◆ GrowthRegulator()

bool Farm::GrowthRegulator ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply growth regulator to a_field.

1251 {
1252 
1253  if (0 >= a_days)
1254  {
1255  if ( (!g_weather->Raining()) && (g_weather->GetWind()<4.5) &&
1256  (!(a_field->GetSignal() & LE_SIG_NO_GROWTH_REG) )) {
1257  a_field->Trace( growth_regulator );
1258  a_field->SetLastTreatment( growth_regulator );
1260  }
1261  return true;
1262  }
1263  else if ( (g_weather->GetWind()<4.5) &&
1264  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
1265  if ( ! (a_field->GetSignal() & LE_SIG_NO_GROWTH_REG) ) {
1266  a_field->Trace( growth_regulator );
1267  a_field->SetLastTreatment( growth_regulator );
1269  }
1270  return true;
1271  }
1272  return false;
1273 }
#define LE_SIG_NO_GROWTH_REG
Definition: elements.h:45
@ growth_regulator
Definition: treatment.h:72

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_weather, LE::GetSignal(), Weather::GetWind(), growth_regulator, LE_SIG_NO_GROWTH_REG, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), and LE::Trace().

◆ HandleEvents()

void Farm::HandleEvents ( void  )
protectedvirtual

If there are events to carry out do this, and perhaps start a new crop.

Call the management plan for the current crop and it this return done=true starts the next management.

Sets the new index to the rotation.

Save the new veg type as the LE vegetation type

Reimplemented in OptimisingFarm.

882  {
883  if ( m_queue.Empty() )
884  return;
885 
887  FarmEvent * ev = pair.m_element;
888  while ( pair.m_pri <= g_date->Date() ) {
889  m_queue.Pop();
891  if ( LeSwitch( ev ) ) {
892  // This crop management plan has terminated.
893 
894  // First check for an infinite loop in the rotation scheme,
895  // ie. a scenario where all crops decide not to run given
896  // the date.
898 
899  // Outdate any remaining events for this field.
900  ev->m_field->BumpRunNum();
901 
902  // Crop treatment done, select and initiate new crop if in rotation.
903  TTypesOfVegetation new_veg = ev->m_field->GetVegType();
904 
905  if ( ev->m_field->GetRotIndex() >= 0 ) {
906  int new_index = GetNextCropIndex( ev->m_field->GetRotIndex() );
907  new_veg = m_rotation[ new_index ];
908  // Running in fixed crop mode?
911  }
913  ev->m_field->SetRotIndex( new_index );
915  ev->m_field->SetVegType(new_veg, tov_Undefined);
916  }
917 
918  // Reset the event list for this field.
919  ev->m_field->ResetTrace();
920  // Reset event timeout counter.
921  ev->m_field->SetVegStore( 0 );
922 
923  // The next bit simply determines the start date of the next crop in
924  // the rotation and passes this to the start crop event.
925  // The crop is responsible for raising an error if the next crop is
926  // not possible or otherwise handling the problem
927 
928  // 19/5-2003: Note: This code was moved out into a dedicated
929  // method of the Farm class, GetNextCropStartDate(), as precisely
930  // the same piece of code needs to be run during initialization of
931  // farm management.
932  TTypesOfVegetation l_tov = new_veg;
933  int l_nextcropstartdate = GetNextCropStartDate( ev->m_field, l_tov );
934 
935  // Create 'start' event for today and put it on the queue.
936  AddNewEvent( new_veg, g_date->Date(), ev->m_field, PROG_START, ev->m_field->GetRunNum(), false, l_nextcropstartdate, false, l_tov );
937 
938  // Set starting date for rotation mgmt loop detection.
940  }
941 
942  delete ev;
943 
944  if ( m_queue.Empty() )
945  return;
946  pair = m_queue.Bottom();
947  ev = pair.m_element;
948  }
949 }
int value(void)
Definition: configurator.h:98
bool LeSwitch(FarmEvent *ev)
Call do function for any crop with an outstanding event. Signal if the crop has terminated.
Definition: farm.cpp:386
void AddNewEvent(TTypesOfVegetation a_event, long a_date, LE *a_field, int a_todo, long a_num, bool a_lock, int a_start, bool a_first_year, TTypesOfVegetation a_crop)
Adds an event to the event queue for a farm.
Definition: farm.cpp:789
void CheckRotationManagementLoop(FarmEvent *ev)
Definition: farm.cpp:839
int GetNextCropStartDate(LE *a_field, TTypesOfVegetation &a_curr_veg)
Returns the start date of the next crop in the rotation.
Definition: farm.cpp:864
TTypesOfVegetation TranslateVegTypes(int VegReference)
Definition: elements.cpp:3088
void ResetTrace(void)
Definition: elements.cpp:467
virtual void SetVegType(TTypesOfVegetation, TTypesOfVegetation)
Definition: elements.h:164
long GetRunNum(void)
Definition: elements.h:117
void SetRotIndex(int a_index)
Definition: elements.h:307
void SetMgtLoopDetectDate(long a_num)
Definition: elements.h:120
void BumpRunNum(void)
Definition: elements.h:118
void SetVegStore(int a_veg)
Definition: elements.h:127
class LE_TypeClass * g_letype
Definition: elements.cpp:277
#define PROG_START
Definition: farm.h:76
CfgInt g_farm_fixed_crop_type("FARM_FIXED_CROP_TYPE", CFG_CUSTOM, 22)
long m_pri
Definition: lowqueue.h:89

References LE::BumpRunNum(), Calendar::Date(), g_date, g_farm_fixed_crop_enable, g_farm_fixed_crop_type, g_letype, LE::GetRotIndex(), LE::GetRunNum(), LE::GetVegType(), LowPriPair< ELEMTYPE >::m_element, FarmEvent::m_field, LowPriPair< ELEMTYPE >::m_pri, PROG_START, LE::ResetTrace(), LE::SetMgtLoopDetectDate(), LE::SetRotIndex(), LE::SetVegStore(), LE::SetVegType(), tov_Undefined, LE_TypeClass::TranslateVegTypes(), CfgInt::value(), and CfgBool::value().

◆ Harvest()

bool Farm::Harvest ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harvest on a_field.

Reimplemented in OptimisingFarm.

1770 {
1771  //5 days good weather before
1772  if ((0 >= a_days) || ((g_weather->GetRainPeriod(g_date->Date(), 5) < 0.1) && DoIt(DO_IT_PROB))) {
1773  a_field->Trace(harvest);
1774  a_field->SetLastTreatment(harvest);
1775  a_field->SetGrowthPhase(harvest1);
1776  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1777  a_field->InsectMortality(0.4);
1778  double insects = a_field->GetInsectPop();
1779  a_field->ResetDigestability();
1780  a_field->RecalculateBugsNStuff();
1781  a_field->SetInsectPop(insects);
1783  int pref = a_field->GetUnsprayedMarginPolyRef();
1784  // Are we a cereal crop? If so we need to have some spilled grain
1785  double someseed = 0.0;
1786  double somemaize = 0.0;
1787  if (dynamic_cast<VegElement*>(a_field)->IsMatureCereal()) {
1788  someseed = m_OurManager->GetSpilledGrain();
1789  a_field->SetStubble(true);
1790  }
1791  else if (dynamic_cast<VegElement*>(a_field)->IsMaize()) {
1792  // Maize in stubble
1793  a_field->SetStubble(true);
1794  somemaize = m_OurManager->GetSpilledMaize();
1795  }
1796  a_field->SetBirdSeed( someseed );
1797  a_field->SetBirdMaize( somemaize );
1798  if (pref != -1){
1799  // Must have an unsprayed margin so need to pass the information on to it
1800  LE* um = g_landscape_p->SupplyLEPointer(pref);
1802  um->SetGrowthPhase(harvest1);
1803  um->InsectMortality(0.4);
1805  um->ResetDigestability();
1806  um->RecalculateBugsNStuff();
1807  um->SetBirdSeed( someseed );
1808  um->SetBirdMaize( somemaize );
1809  if ((somemaize > 0) || (someseed > 0)) um->SetStubble(true);
1810  }
1811  return true;
1812  }
1813  return false;
1814 }
double GetSpilledGrain()
Returns the average amount of spilled grain in KJ/m2 this year.
Definition: farm.cpp:3033
double GetSpilledMaize()
Returns the average amount of spilled maize in KJ/m2 this year.
Definition: farm.cpp:3064
void SetBirdMaize(double a_forage)
Definition: elements.h:213
void SetStubble(bool a_flag)
Sets the in stubble flag.
Definition: elements.h:390
void SetBirdSeed(double a_forage)
Definition: elements.h:201
Definition: elements.h:568
@ harvest
Definition: treatment.h:82

References Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_landscape_p, g_weather, LE::GetInsectPop(), Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), harvest, harvest1, LE::InsectMortality(), LE::RecalculateBugsNStuff(), LE::ResetDigestability(), LE::SetBirdMaize(), LE::SetBirdSeed(), LE::SetGrowthPhase(), LE::SetInsectPop(), LE::SetLastTreatment(), LE::SetStubble(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ HarvestLong()

bool Farm::HarvestLong ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a harvest on a_field.

1822 {
1823 
1824  //5 days good weather before
1825  if ((0 >= a_days) ||
1827  ) {
1828  a_field->Trace(harvest);
1829  a_field->SetLastTreatment(harvest);
1830  a_field->SetGrowthPhase(harvest1);
1831  // Here we have to do a little skip to avoid too low insect populations after harvest, but a correct veg biomass
1832  a_field->InsectMortality(0.4);
1833  double insects = a_field->GetInsectPop();
1834  a_field->ResetDigestability();
1835  a_field->RecalculateBugsNStuff();
1836  a_field->SetInsectPop(insects);
1838  int pref = a_field->GetUnsprayedMarginPolyRef();
1839  double someseed = 0.0; //No bird seed or maize forage on sugar beet (which is currently (March 2015) the only crop using HarvestLong.
1840  a_field->SetBirdSeed( someseed );
1841  a_field->SetBirdMaize( someseed );
1842  if (pref != -1){
1843  // Must have an unsprayed margin so need to pass the information on to it
1844  LE* um = g_landscape_p->SupplyLEPointer(pref);
1846  um->SetGrowthPhase(harvest1);
1847  um->InsectMortality(0.4);
1849  um->ResetDigestability();
1850  um->RecalculateBugsNStuff();
1851  um->SetBirdSeed( someseed );
1852  um->SetBirdMaize( someseed );
1853  }
1854  return true;
1855  }
1856  return false;
1857 }
#define DO_IT_PROB_LONG
Definition: farmfuncs.cpp:57

References Calendar::Date(), DO_IT_PROB_LONG, EL_TRAMLINE_DECAYTIME, g_date, g_landscape_p, g_weather, LE::GetInsectPop(), Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), harvest, harvest1, LE::InsectMortality(), LE::RecalculateBugsNStuff(), LE::ResetDigestability(), LE::SetBirdMaize(), LE::SetBirdSeed(), LE::SetGrowthPhase(), LE::SetInsectPop(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ HayBailing()

bool Farm::HayBailing ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay bailing on a_field.

2185 {
2186 
2187  if ( (0 >= a_days) ||
2188  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
2189  ) {
2190  a_field->Trace( hay_bailing );
2191  a_field->SetLastTreatment( hay_bailing );
2193  int pref=a_field->GetUnsprayedMarginPolyRef();
2194  if (pref!=-1){
2195  // Must have an unsprayed margin so need to pass the information on to it
2196  LE* um=g_landscape_p->SupplyLEPointer(pref);
2199  }
2200  return true;
2201  }
2202  return false;
2203 }
@ hay_bailing
Definition: treatment.h:89

References Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_landscape_p, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), hay_bailing, LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ HayTurning()

bool Farm::HayTurning ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out hay turning on a_field.

2160 {
2161 
2162  if ( (0 >= a_days) ||
2163  ((g_weather->GetRainPeriod(g_date->Date(),5)<0.1) && DoIt(DO_IT_PROB))
2164  ) {
2165  a_field->Trace( hay_turning );
2166  a_field->SetLastTreatment( hay_turning );
2168  int pref=a_field->GetUnsprayedMarginPolyRef();
2169  if (pref!=-1){
2170  // Must have an unsprayed margin so need to pass the information on to it
2171  LE* um=g_landscape_p->SupplyLEPointer(pref);
2174  }
2175  return true;
2176  }
2177  return false;
2178 }
@ hay_turning
Definition: treatment.h:88

References Calendar::Date(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_date, g_landscape_p, g_weather, Weather::GetRainPeriod(), LE::GetUnsprayedMarginPolyRef(), hay_turning, LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ HeavyCultivatorAggregate()

bool Farm::HeavyCultivatorAggregate ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Carry out a heavy cultivation event on a_field. This is non-inversion type of cultivation which can be done after fertilizers application on spring for a spring crop.

218 {
219  if ((0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
222  a_field->InsectMortality(0.1); // The same global mortality as for normal plough
223  a_field->ZeroVeg(); // Zero veg as with stubble harrowing
224  int pref = a_field->GetUnsprayedMarginPolyRef();
225  if (pref != -1) {
226  // Must have an unsprayed margin so need to pass the information on to it
227  LE* um = g_landscape_p->SupplyLEPointer(pref);
229  um->InsectMortality(0.1);
230  um->ZeroVeg();
231  }
232  return true; // completed
233  }
234  return false; // not completed
235 }
@ heavy_cultivator_aggregate
Definition: treatment.h:108

References DO_IT_PROB, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), heavy_cultivator_aggregate, LE::InsectMortality(), Weather::Raining(), LE::SetLastTreatment(), Landscape::SupplyLEPointer(), LE::Trace(), and LE::ZeroVeg().

◆ HerbicideTreat()

bool Farm::HerbicideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply herbicide to a_field.

Reimplemented in OptimisingFarm.

1157 {
1158 
1159  if (0 >= a_days) // Must do this
1160  {
1161  if (((a_field->GetSignal() & LE_SIG_NO_HERBICIDE)==0 ))
1162  {
1163  a_field->Trace( herbicide_treat );
1164  a_field->SetLastTreatment( herbicide_treat );
1165  if ( l_farm_herbicide_kills.value())
1166  {
1167  a_field->ReduceWeedBiomass( 0.05 );
1168  }
1172 
1173  }
1174  return true;
1175  }
1176  else if ((g_weather->GetWind()<4.5) && (!g_weather->Raining()) && DoIt(DO_IT_PROB))
1177  {
1178  if ( !(a_field->GetSignal() & LE_SIG_NO_HERBICIDE) )
1179  {
1180  a_field->Trace( herbicide_treat );
1181  a_field->SetLastTreatment( herbicide_treat );
1182  if ( l_farm_herbicide_kills.value())
1183  {
1184  a_field->ReduceWeedBiomass( 0.05 );
1185  }
1189  }
1190  return true;
1191  }
1192  return false;
1193 }
virtual void ReduceWeedBiomass(double)
Definition: elements.h:160
void SetHerbicideDelay(int a_decaytime_days)
Definition: elements.h:312
#define LE_SIG_NO_HERBICIDE
Definition: elements.h:47
#define EL_HERBICIDE_DELAYTIME
Definition: elements.h:60
static CfgBool l_farm_herbicide_kills("FARM_PESTICIDE_KILLS", CFG_CUSTOM, true)
@ herbicide
Definition: landscape.h:63
@ herbicide_treat
Definition: treatment.h:71

References Landscape::CheckForPesticideRecord(), DO_IT_PROB, EL_HERBICIDE_DELAYTIME, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, LE::GetSignal(), Weather::GetWind(), herbicide, herbicide_treat, l_farm_herbicide_kills, LE_SIG_NO_HERBICIDE, Weather::Raining(), LE::ReduceWeedBiomass(), LE::SetHerbicideDelay(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), and CfgBool::value().

◆ HillingUp()

bool Farm::HillingUp ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Do hilling up on a_field, probably of potatoes.

1664 {
1665 
1666  if ( (0 >= a_days) || (!g_weather->Raining() && DoIt(DO_IT_PROB))) {
1667  a_field->Trace( hilling_up );
1668  a_field->SetLastTreatment( hilling_up );
1669  a_field->InsectMortality( 0.75 );
1670  a_field->ReduceWeedBiomass( 0.25 );
1672  int pref=a_field->GetUnsprayedMarginPolyRef();
1673  if (pref!=-1){
1674  // Must have an unsprayed margin so need to pass the information on to it
1675  LE* um=g_landscape_p->SupplyLEPointer(pref);
1677  um->ReduceWeedBiomass( 0.25 );
1678  um->InsectMortality( 0.75 );
1680  }
1681  return true;
1682  }
1683  return false;
1684 }
@ hilling_up
Definition: treatment.h:79

References DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, LE::GetUnsprayedMarginPolyRef(), hilling_up, LE::InsectMortality(), Weather::Raining(), LE::ReduceWeedBiomass(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), Landscape::SupplyLEPointer(), and LE::Trace().

◆ InitiateManagement()

void Farm::InitiateManagement ( void  )
virtual

Kicks off the farm's management.

Reimplemented in OptimisingFarm, and UserDefinedFarm.

1514  {
1515  for ( unsigned int i = 0; i < m_fields.size(); i++ ) {
1516  int rot_index = m_fields[ i ]->GetRotIndex();
1518  // If the field has been designated as non-rotating and therefore already has its veg type, then skip it.
1519  if ( rot_index < -1 ) {
1520  // Check for any type of permanent element type with management plan.
1521  TTypesOfLandscapeElement ele = m_fields[ i ]->GetElementType();
1522  switch (ele) {
1524  new_veg = tov_PermanentGrassLowYield;
1525  break;
1526  case tole_YoungForest:
1527  new_veg = tov_YoungForest;
1528  break;
1529  case tole_PermPasture:
1530  new_veg = tov_PermanentGrassGrazed;
1531  break;
1533  new_veg = tov_PermanentGrassTussocky;
1534  break;
1536  new_veg = tov_PermanentSetaside;
1537  break;
1538  case tole_Orchard:
1539  new_veg = tov_OrchardCrop;
1540  break;
1541  case tole_PlantNursery:
1542  new_veg = tov_PlantNursery;
1543  break;
1544  default:
1545  if (rot_index != -4) {
1546  // Error
1547  g_msg->Warn("Unexpected negative value in Farm::InitiateManagement","");
1548  exit(0);
1549  }
1550  else
1551  {
1552  new_veg = m_fields[i]->GetVegType();
1553  }
1554  }
1555  }
1556  else {
1557  rot_index = GetFirstCropIndex( m_fields[ i ]->GetElementType() );
1558  new_veg = m_rotation[ rot_index ];
1559  }
1560  // Running in fixed crop mode?
1561  if ( g_farm_fixed_crop_enable.value() ) {
1562  int fv = g_farm_fixed_crop_type.value();
1563  new_veg = g_letype->TranslateVegTypes( fv );
1564  }
1565  m_fields[ i ]->SetVegType( new_veg, tov_Undefined );
1566  m_fields[ i ]->SetRotIndex( rot_index );
1567  m_fields[ i ]->SetGrowthPhase( janfirst );
1568  // Reset event timeout counter. We are now 800 days from
1569  // oblivion.
1570  long prog_start_date = g_date->Date();
1571  m_fields[ i ]->SetVegStore( 0 );
1572  TTypesOfVegetation l_tov = new_veg;
1573  int l_nextcropstartdate = GetNextCropStartDate( m_fields[ i ], l_tov );
1574  AddNewEvent( new_veg, prog_start_date, m_fields[ i ], PROG_START, 0, false, l_nextcropstartdate, true, l_tov );
1575  }
1576 }
virtual int GetFirstCropIndex(TTypesOfLandscapeElement a_type)
Gets the first crop for the farm.
Definition: farm.cpp:1385
@ janfirst
Definition: plants.h:52
@ tov_PlantNursery
Definition: tov_declaration.h:66

References Calendar::Date(), g_date, g_farm_fixed_crop_enable, g_farm_fixed_crop_type, g_letype, g_msg, janfirst, PROG_START, tole_Orchard, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PlantNursery, tole_YoungForest, tov_OrchardCrop, tov_PermanentGrassGrazed, tov_PermanentGrassLowYield, tov_PermanentGrassTussocky, tov_PermanentSetaside, tov_PlantNursery, tov_Undefined, tov_YoungForest, LE_TypeClass::TranslateVegTypes(), CfgInt::value(), CfgBool::value(), and MapErrorMsg::Warn().

Referenced by UserDefinedFarm::InitiateManagement(), and OptimisingFarm::InitiateManagement().

◆ InsecticideTreat()

bool Farm::InsecticideTreat ( LE a_field,
double  a_user,
int  a_days 
)
virtual

Apply insecticide to a_field.

Reimplemented in OptimisingFarm.

1349 {
1350 
1351  if (0 >= a_days)
1352  {
1353  if (( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE) ))
1354  {
1355  // **CJT** Turn this code on to use the pesticide engine with insecticides
1356  // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
1357  //
1358  a_field->Trace( insecticide_treat );
1359  a_field->SetLastTreatment( insecticide_treat );
1361  {
1362  a_field->Insecticide( 0.36 );
1363  }
1366  }
1367  return true;
1368  }
1369  else if ( (g_weather->GetWind()<4.5) &&
1370  (!g_weather->Raining()) && DoIt(DO_IT_PROB)) {
1371  if ( ! (a_field->GetSignal() & LE_SIG_NO_INSECTICIDE )) {
1372 // **CJT** Turn this code on to use the pesticide engine with insecticides
1373 // g_pest->DailyQueueAdd( a_field, l_pest_insecticide_amount.value());
1374 //
1375  a_field->Trace( insecticide_treat );
1376  a_field->SetLastTreatment( insecticide_treat );
1378  a_field->Insecticide( 0.36 );
1379  }
1382  }
1383  return true;
1384  }
1385  return false;
1386 }
virtual void Insecticide(double)
Definition: elements.h:158
#define LE_SIG_NO_INSECTICIDE
Definition: elements.h:43
static CfgBool l_farm_insecticide_kills("FARM_INSECTICIDE_KILLS", CFG_CUSTOM, true)
@ insecticide
Definition: landscape.h:63
@ insecticide_treat
Definition: treatment.h:74

References Landscape::CheckForPesticideRecord(), DO_IT_PROB, EL_TRAMLINE_DECAYTIME, g_landscape_p, g_weather, LE::GetSignal(), Weather::GetWind(), LE::Insecticide(), insecticide, insecticide_treat, l_farm_insecticide_kills, LE_SIG_NO_INSECTICIDE, Weather::Raining(), LE::SetLastTreatment(), LE::SetTramlinesDecay(), LE::Trace(), and CfgBool::value().

◆ InvIntPartition()

int Farm::InvIntPartition ( vector< tpct > *  items,
int  target 
)
protected

Finds all possible sums of the integers in the items array.

2493  {
2494  //Figure out how many bitmasks we need...
2495  //4 bits have a maximum value of 15, so we need 15 masks.
2496  //Calculated as:
2497  // (2 ^ ItemCount) - 1
2498  long long int sz = (long long int) items->size();
2499  if (sz>80) {
2500  // This is a warning that we did no consider all combinations of fields but 2^63 combinations should be enough :)
2501  g_msg->Warn("Too many potential fields in UserDefinedFarm::InvIntPartition: ",sz);
2502  g_msg->Warn("Farm Number: ",GetFarmNumber());
2503  sz = 63;
2504  }
2505  long int calcs = (1 << sz);
2506  //Spit out the corresponding calculation for each bitmask
2507  int sum;
2508  int found = 0;
2509  int diff = 100;
2510  for (long int i=1; i<calcs; i++) {
2511  //Get the items from our array that correspond to
2512  //the on bits in our mask
2513  sum = 0;
2514  int mask = 1;
2515  for (int bit=0; bit<sz; bit++) {
2516  if ((i & mask) > 0) {
2517  sum+=(*items)[bit].pct;
2518  }
2519  mask = mask << 1;
2520  }
2521 
2522  if (abs(sum-target) < diff ){
2523  found = i;
2524  diff = abs(sum-target);
2525  if (diff<1) break; //added 01.11.12 to prevent from checking all the combinations when the right one is found
2526  }
2527  }
2528  return found;
2529 }
int GetFarmNumber(void)
Definition: farm.h:782

References g_msg, GetFarmNumber(), and MapErrorMsg::Warn().

Referenced by AssignPermanentCrop().

◆ IsStockFarmer()

bool Farm::IsStockFarmer ( void  )
inline
905 { return m_stockfarmer; }

References m_stockfarmer.

◆ LeSwitch()

bool Farm::LeSwitch ( FarmEvent ev)
protected

Call do function for any crop with an outstanding event. Signal if the crop has terminated.

386  {
387  // Ignore this event if it is from the execution of
388  // a previous management plan.
389  if (ev->m_field->GetRunNum() > ev->m_run)
390  return false;
391  // Store what we are trying to do this time.
392  // ***FN*** To be cleaned up later.
393  ev->m_field->m_tried_to_do = ev->m_todo;
394  bool done;
395 
396  switch (ev->m_event) {
397  case tov_Carrots:
398  done = m_carrots->Do( this, ev->m_field, ev );
399  break;
400  case tov_BroadBeans:
401  done = m_broadbeans->Do( this, ev->m_field, ev );
402  break;
403  case tov_FodderGrass:
404  done = m_foddergrass->Do( this, ev->m_field, ev );
405  break;
407  done = m_CGG1->Do( this, ev->m_field, ev );
408  break;
410  done = m_CGG2->Do( this, ev->m_field, ev );
411  break;
412  case tov_FieldPeas:
413  done = m_fieldpeas->Do( this, ev->m_field, ev );
414  break;
415  case tov_FieldPeasSilage:
416  done = m_fieldpeassilage->Do( this, ev->m_field, ev );
417  break;
418  case tov_FodderBeet:
419  done = m_fodderbeet->Do( this, ev->m_field, ev );
420  break;
421  case tov_SugarBeet:
422  done = m_sugarbeet->Do( this, ev->m_field, ev );
423  break;
424  case tov_OFodderBeet:
425  done = m_ofodderbeet->Do( this, ev->m_field, ev );
426  break;
427  case tov_Maize:
428  done = m_maize->Do( this, ev->m_field, ev );
429  break;
431  done = m_OBarleyPCG->Do( this, ev->m_field, ev );
432  break;
433  case tov_OCarrots:
434  done = m_ocarrots->Do( this, ev->m_field, ev );
435  break;
437  done = m_OCGS1->Do( this, ev->m_field, ev );
438  break;
440  done = m_OCGG1->Do( this, ev->m_field, ev );
441  break;
443  done = m_OCGG2->Do( this, ev->m_field, ev );
444  break;
445  case tov_OFieldPeas:
446  done = m_ofieldpeas->Do( this, ev->m_field, ev );
447  break;
449  done = m_ofieldpeassilage->Do( this, ev->m_field, ev );
450  break;
451  case tov_OGrazingPigs:
452  done = m_ograzingpigs->Do( this, ev->m_field, ev );
453  break;
454  case tov_OrchardCrop:
455  done = m_orchardcrop->Do( this, ev->m_field, ev );
456  break;
457  case tov_OOats:
458  done = m_ooats->Do( this, ev->m_field, ev );
459  break;
460  case tov_Oats:
461  done = m_oats->Do( this, ev->m_field, ev );
462  break;
464  done = m_opermgrassgrazed->Do( this, ev->m_field, ev );
465  break;
466  case tov_OPotatoes:
467  done = m_opotatoes->Do( this, ev->m_field, ev );
468  break;
469  case tov_OSpringBarley:
470  done = m_ospringbarley->Do( this, ev->m_field, ev );
471  break;
472  case tov_OSBarleySilage:
473  done = m_osbarleysilage->Do( this, ev->m_field, ev );
474  break;
475  case tov_OSeedGrass1:
476  done = m_oseedgrass1->Do( this, ev->m_field, ev );
477  break;
478  case tov_OSeedGrass2:
479  done = m_oseedgrass2->Do( this, ev->m_field, ev );
480  break;
482  done = m_ospringbarleyext->Do( this, ev->m_field, ev );
483  break;
485  done = m_ospringbarleypigs->Do( this, ev->m_field, ev );
486  break;
487  case tov_OWinterBarley:
488  done = m_owinterbarley->Do( this, ev->m_field, ev );
489  break;
491  done = m_owinterbarleyext->Do( this, ev->m_field, ev );
492  break;
494  done = m_owinterwheatundersown->Do( this, ev->m_field, ev );
495  break;
496  case tov_OWinterWheat:
497  done = m_owinterwheat->Do( this, ev->m_field, ev );
498  break;
500  done = m_owinterwheatundersownext->Do( this, ev->m_field, ev );
501  break;
502  case tov_OWinterRape:
503  done = m_owinterrape->Do( this, ev->m_field, ev );
504  break;
505  case tov_OWinterRye:
506  done = m_owinterrye->Do( this, ev->m_field, ev );
507  break;
509  done = m_permgrassgrazed->Do( this, ev->m_field, ev );
510  break;
512  done = m_permgrasslowyield->Do( this, ev->m_field, ev );
513  break;
515  done = m_permgrasstussocky->Do( this, ev->m_field, ev );
516  break;
518  done = m_permanentsetaside->Do( this, ev->m_field, ev );
519  break;
520  case tov_Potatoes:
521  done = m_potatoes->Do( this, ev->m_field, ev );
522  break;
524  done = m_potatoesindustry->Do( this, ev->m_field, ev );
525  break;
526  case tov_SeedGrass1:
527  done = m_seedgrass1->Do( this, ev->m_field, ev );
528  break;
529  case tov_SeedGrass2:
530  done = m_seedgrass2->Do( this, ev->m_field, ev );
531  break;
532  case tov_Setaside:
533  done = m_setaside->Do( this, ev->m_field, ev );
534  break;
535  case tov_SpringBarley:
536  done = m_springbarley->Do( this, ev->m_field, ev );
537  break;
538  case tov_SpringBarleySpr:
539  done = m_springbarleyspr->Do( this, ev->m_field, ev );
540  break;
542  done = m_springbarleyptreatment->Do( this, ev->m_field, ev );
543  break;
545  done = m_springbarleyskmanagement->Do( this, ev->m_field, ev );
546  break;
548  done = m_sbarleyclovergrass->Do( this, ev->m_field, ev );
549  break;
551  done = m_springbarleyseed->Do( this, ev->m_field, ev );
552  break;
554  done = m_springbarleysilage->Do( this, ev->m_field, ev );
555  break;
556  case tov_SpringRape:
557  done = m_springrape->Do( this, ev->m_field, ev );
558  break;
559  case tov_Triticale:
560  done = m_triticale->Do( this, ev->m_field, ev );
561  break;
562  case tov_OTriticale:
563  done = m_otriticale->Do( this, ev->m_field, ev );
564  break;
565  case tov_WinterBarley:
566  done = m_winterbarley->Do( this, ev->m_field, ev );
567  break;
568  case tov_WinterRape:
569  done = m_winterrape->Do( this, ev->m_field, ev );
570  break;
571  case tov_WinterRye:
572  done = m_winterrye->Do( this, ev->m_field, ev );
573  break;
574  case tov_WinterWheat:
575  done = m_winterwheat->Do( this, ev->m_field, ev );
576  break;
577  case tov_WWheatPControl:
578  done = m_wwheatpcontrol->Do( this, ev->m_field, ev );
579  break;
581  done = m_wwheatptoxiccontrol->Do( this, ev->m_field, ev );
582  break;
584  done = m_wwheatptreatment->Do( this, ev->m_field, ev );
585  break;
587  done = m_agrochemindustrycereal->Do( this, ev->m_field, ev );
588  break;
590  done = m_winterwheatstrigling->Do( this, ev->m_field, ev );
591  break;
593  done = m_winterwheatstriglingsingle->Do( this, ev->m_field, ev );
594  break;
596  done = m_winterwheatstriglingculm->Do( this, ev->m_field, ev );
597  break;
599  done = m_springbarleyclovergrassstrigling->Do( this, ev->m_field, ev );
600  break;
602  done = m_springbarleystrigling->Do( this, ev->m_field, ev );
603  break;
605  done = m_springbarleystriglingsingle->Do( this, ev->m_field, ev );
606  break;
608  done = m_springbarleystriglingculm->Do( this, ev->m_field, ev );
609  break;
610  case tov_MaizeStrigling:
611  done = m_maizestrigling->Do( this, ev->m_field, ev );
612  break;
613  case tov_MaizeSilage:
614  done = m_maizesilage->Do( this, ev->m_field, ev );
615  break;
616  case tov_OMaizeSilage:
617  done = m_omaizesilage->Do( this, ev->m_field, ev );
618  break;
620  done = m_winterrapestrigling->Do( this, ev->m_field, ev );
621  break;
623  done = m_winterryestrigling->Do( this, ev->m_field, ev );
624  break;
626  done = m_winterbarleystrigling->Do( this, ev->m_field, ev );
627  break;
629  done = m_fieldpeasstrigling->Do( this, ev->m_field, ev );
630  break;
632  done = m_springbarleypeaclovergrassstrigling->Do( this, ev->m_field, ev );
633  break;
634  case tov_PlantNursery:
635  // uses youngforest management because this effectively does nothing, but stops the crop management creating looping error
636  case tov_YoungForest:
637  done = m_youngforest->Do(this, ev->m_field, ev);
638  break;
640  done = m_norwegianpotatoes->Do(this, ev->m_field, ev);
641  break;
642  case tov_NorwegianOats:
643  done = m_norwegianoats->Do(this, ev->m_field, ev);
644  break;
646  done = m_norwegianspringbarley->Do(this, ev->m_field, ev);
647  break;
648 
649  case tov_PLWinterWheat:
650  done = m_plwinterwheat->Do(this, ev->m_field, ev);
651  break;
652  case tov_PLWinterRape:
653  done = m_plwinterrape->Do(this, ev->m_field, ev);
654  break;
655  case tov_PLWinterBarley:
656  done = m_plwinterbarley->Do(this, ev->m_field, ev);
657  break;
659  done = m_plwintertriticale->Do(this, ev->m_field, ev);
660  break;
661  case tov_PLWinterRye:
662  done = m_plwinterrye->Do(this, ev->m_field, ev);
663  break;
664  case tov_PLSpringWheat:
665  done = m_plspringwheat->Do(this, ev->m_field, ev);
666  break;
667  case tov_PLSpringBarley:
668  done = m_plspringbarley->Do(this, ev->m_field, ev);
669  break;
670  case tov_PLMaize:
671  done = m_plmaize->Do(this, ev->m_field, ev);
672  break;
673  case tov_PLMaizeSilage:
674  done = m_plmaizesilage->Do(this, ev->m_field, ev);
675  break;
676  case tov_PLPotatoes:
677  done = m_plpotatoes->Do(this, ev->m_field, ev);
678  break;
679  case tov_PLBeet:
680  done = m_plbeet->Do(this, ev->m_field, ev);
681  break;
683  done = m_plfodderlucerne1->Do(this, ev->m_field, ev);
684  break;
686  done = m_plfodderlucerne2->Do(this, ev->m_field, ev);
687  break;
688  case tov_PLCarrots:
689  done = m_plcarrots->Do(this, ev->m_field, ev);
690  break;
692  done = m_plspringbarleyspr->Do(this, ev->m_field, ev);
693  break;
695  done = m_plwinterwheatlate->Do(this, ev->m_field, ev);
696  break;
697  case tov_PLBeetSpr:
698  done = m_plbeetspr->Do(this, ev->m_field, ev);
699  break;
700  case tov_PLBeans:
701  done = m_plbeans->Do(this, ev->m_field, ev);
702  break;
703 
704  case tov_NLBeet:
705  done = m_nlbeet->Do(this, ev->m_field, ev);
706  break;
707  case tov_NLCarrots:
708  done = m_nlcarrots->Do(this, ev->m_field, ev);
709  break;
710  case tov_NLMaize:
711  done = m_nlmaize->Do(this, ev->m_field, ev);
712  break;
713  case tov_NLPotatoes:
714  done = m_nlpotatoes->Do(this, ev->m_field, ev);
715  break;
716  case tov_NLSpringBarley:
717  done = m_nlspringbarley->Do(this, ev->m_field, ev);
718  break;
719  case tov_NLWinterWheat:
720  done = m_nlwinterwheat->Do(this, ev->m_field, ev);
721  break;
722  case tov_NLCabbage:
723  done = m_nlcabbage->Do(this, ev->m_field, ev);
724  break;
725  case tov_NLTulips:
726  done = m_nltulips->Do(this, ev->m_field, ev);
727  break;
728  case tov_NLGrassGrazed1:
729  done = m_nlgrassgrazed1->Do(this, ev->m_field, ev);
730  break;
732  done = m_nlgrassgrazed1spring->Do(this, ev->m_field, ev);
733  break;
734  case tov_NLGrassGrazed2:
735  done = m_nlgrassgrazed2->Do(this, ev->m_field, ev);
736  break;
738  done = m_nlgrassgrazedlast->Do(this, ev->m_field, ev);
739  break;
741  done = m_nlpermanentgrassgrazed->Do(this, ev->m_field, ev);
742  break;
743  case tov_NLBeetSpring:
744  done = m_nlbeetspring->Do(this, ev->m_field, ev);
745  break;
746  case tov_NLCarrotsSpring:
747  done = m_nlcarrotsspring->Do(this, ev->m_field, ev);
748  break;
749  case tov_NLMaizeSpring:
750  done = m_nlmaizespring->Do(this, ev->m_field, ev);
751  break;
753  done = m_nlpotatoesspring->Do(this, ev->m_field, ev);
754  break;
756  done = m_nlspringbarleyspring->Do(this, ev->m_field, ev);
757  break;
758  case tov_NLCabbageSpring:
759  done = m_nlcabbagespring->Do(this, ev->m_field, ev);
760  break;
761  case tov_NLCatchPeaCrop:
762  done = m_nlcatchpeacrop->Do(this, ev->m_field, ev);
763  break;
764 
766  done = m_dummycroppesttesting->Do(this, ev->m_field, ev);
767  break;
768 
769  case tov_Lawn:
770  // No current actions
771  done = true;
772  break;
773  /* case tov_OFirstYearDanger: done = m_ofirstyeardanger->Do( this, ev->m_field, ev ); break; */
774  default:
775  char veg_type[ 20 ];
776  sprintf( veg_type, "%d", ev->m_event );
777  g_msg->Warn( WARN_FILE, "Farm::LeSwitch(): ""Unknown crop type: ", veg_type );
778  exit( 1 );
779 
780  }
781  return done;
782 }
int m_tried_to_do
Definition: elements.h:85
@ WARN_FILE
Definition: maperrormsg.h:37
TTypesOfVegetation m_event
Definition: farm.h:470
int m_todo
Definition: farm.h:469
long m_run
Definition: farm.h:468
@ tov_WinterRyeStrigling
Definition: tov_declaration.h:59
@ tov_MaizeStrigling
Definition: tov_declaration.h:58
@ tov_SpringBarleyPeaCloverGrassStrigling
Definition: tov_declaration.h:60
@ tov_SpringBarleyCloverGrassStrigling
Definition: tov_declaration.h:58
@ tov_PotatoesIndustry
Definition: tov_declaration.h:50
@ tov_OSeedGrass1
Definition: tov_declaration.h:46
@ tov_Lawn
Definition: tov_declaration.h:63
@ tov_OFieldPeasSilage
Definition: tov_declaration.h:56
@ tov_OSeedGrass2
Definition: tov_declaration.h:46
@ tov_WinterRapeStrigling
Definition: tov_declaration.h:59
@ tov_WinterBarleyStrigling
Definition: tov_declaration.h:59
@ tov_FieldPeasStrigling
Definition: tov_declaration.h:56

References g_msg, LE::GetRunNum(), FarmEvent::m_event, FarmEvent::m_field, FarmEvent::m_run, FarmEvent::m_todo, LE::m_tried_to_do, tov_AgroChemIndustryCereal, tov_BroadBeans, tov_Carrots, tov_CloverGrassGrazed1, tov_CloverGrassGrazed2, tov_DummyCropPestTesting, tov_FieldPeas, tov_FieldPeasSilage, tov_FieldPeasStrigling, tov_FodderBeet, tov_FodderGrass, tov_Lawn, tov_Maize, tov_MaizeSilage, tov_MaizeStrigling, tov_NLBeet, tov_NLBeetSpring, tov_NLCabbage, tov_NLCabbageSpring, tov_NLCarrots, tov_NLCarrotsSpring, tov_NLCatchPeaCrop, tov_NLGrassGrazed1, tov_NLGrassGrazed1Spring, tov_NLGrassGrazed2, tov_NLGrassGrazedLast, tov_NLMaize, tov_NLMaizeSpring, tov_NLPermanentGrassGrazed,